From: Martin Mares Date: Tue, 8 Jan 2008 16:16:29 +0000 (+0100) Subject: Pridana utilitka pro opravovani postscriptu, ktery vylezl z pstops. X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=bfc2aa2af55a14b6a12b86ad04acf084851165ea;p=ads2.git Pridana utilitka pro opravovani postscriptu, ktery vylezl z pstops. --- diff --git a/Makerules b/Makerules index c2a6492..e3910b9 100644 --- a/Makerules +++ b/Makerules @@ -15,10 +15,10 @@ all: $P.ps dvipdfm -o $@ -x 9mm -y 9mm -p a5 -r 600 -z 9 $< %-booklet.ps: %.ps - psbook <$< | pstops '2:0L(210mm,0)+1L(210mm,148mm)' | sed 's/^%%BoundingBox: .*/%%BoundingBox: 0 0 595 842/;s/^%%DocumentPaperSizes:.*/%%DocumentPaperSizes: a4\n%%Orientation: Landscape/' >$@ + psbook <$< | pstops '2:0L(210mm,0)+1L(210mm,148mm)' | ../utils/pstopsfix | sed 's/^%%BoundingBox: .*/%%BoundingBox: 0 0 595 842/;s/^%%DocumentPaperSizes:.*/%%DocumentPaperSizes: a4\n%%Orientation: Landscape/' >$@ %-2in1.ps: %.ps - pstops '2:0L(210mm,0mm)+1L(210mm,148mm)' <$< | sed 's/^%%BoundingBox: .*/%%BoundingBox: 0 0 595 842/;s/^%%DocumentPaperSizes:.*/%%DocumentPaperSizes: a4\n%%Orientation: Landscape/' >$@ + pstops '2:0L(210mm,0mm)+1L(210mm,148mm)' <$< | ../utils/pstopsfix | sed 's/^%%BoundingBox: .*/%%BoundingBox: 0 0 595 842/;s/^%%DocumentPaperSizes:.*/%%DocumentPaperSizes: a4\n%%Orientation: Landscape/' >$@ mostlyclean: rm -f *.dvi *.log *~ core *.o *.aux *.bbl *.blg diff --git a/utils/pstopsfix b/utils/pstopsfix new file mode 100755 index 0000000..bdea303 --- /dev/null +++ b/utils/pstopsfix @@ -0,0 +1,35 @@ +#!/usr/bin/perl +# A filter for fixing PS generated by pstops +# (c) 2008 Martin Mares + +my $seen_procset = 0; +my @procset = (); +my $seen_setup = 0; +while (<>) { + if (/^%%BeginProcSet: PStoPS/) { + $seen_procset = 1; + } elsif ($seen_procset == 1) { + if (/^%%EndProcSet/) { + $seen_procset = 2; + } else { + push @procset, $_; + } + } elsif (/^%%BeginSetup/) { + print; + if ($seen_procset == 2) { + print "%%BeginFeature: PStoPS\n"; + print join("", @procset); + print "%%EndFeature\n"; + $seen_procset = 3; + } + $seen_setup = 1; + } else { + print; + } +} + +$seen_setup or die "No setup section seen\n"; +$seen_procset or die "No PStoPS procset seen\n"; +$seen_procset >= 2 or die "PStoPS procset not terminated\n"; +$seen_procset >= 3 or die "Setup section precedes PStoPS procset\n"; +exit 0;