]> mj.ucw.cz Git - ads2.git/commitdiff
Pridana utilitka pro opravovani postscriptu, ktery vylezl z pstops.
authorMartin Mares <mj@ucw.cz>
Tue, 8 Jan 2008 16:16:29 +0000 (17:16 +0100)
committerMartin Mares <mj@ucw.cz>
Tue, 8 Jan 2008 16:16:29 +0000 (17:16 +0100)
Makerules
utils/pstopsfix [new file with mode: 0755]

index c2a64928554341daaef2c9bef9c4bb9fed587e8c..e3910b9308fda9bfdb9bed85f3241f88701e430d 100644 (file)
--- 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 (executable)
index 0000000..bdea303
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+# A filter for fixing PS generated by pstops
+# (c) 2008 Martin Mares <mj@ucw.cz>
+
+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;