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
--- /dev/null
+#!/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;