#!/usr/local/bin/perl ###################################################################### # Perl font split impose # # Copyright (C) 1999 Dov Grobgeld # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # For more details see the file COPYING. ###################################################################### # Get options while($_ = $ARGV[0], /^-/) { shift; /^-lastbbox/ and do { $lastbbox="-lastbbox"; next; }; /^-lpi/ and do { $lpi = shift; next; }; /^-impose_options/ and do { $impose_options = shift; next; }; /^-max(_pages)?/ and do { $max_pages_per_signature = shift; next; }; /^-help/ and print< $pages) { $end = $pages; } $cmd = "psselect $start-$end $psname | fixtd -tumble | psbook > $psname.$start-$end"; print "$cmd\n"; system $cmd; $lastbbox = "-lastbbox" if $i > 0; $cmd = "impose $impose_options $lastbbox $psname.$start-$end"; print "$cmd\n"; system $cmd; unlink "$psname.$start-$end"; } print "Done!\n"; sub get_num_pages { my $fn = shift; my $pages; open(PS, $fn) || die "Couldn't open $fn: $!\n"; while() { if ($. == 1) { die "Not a Postscript file!\n" unless /^%!/; } $pages = $_ and last if /^%%Pages:/; } die "Couldn't find %%Pages!\n" unless $pages; if ($pages =~ /atend/) { seek(PS, -2000, 2); read(PS, $_, 2000); /^%%Pages:.*$/m or die "Couldn't find %%Pages at end of file!\n"; $pages = $&; } $pages=~ /(\d+)\S*(\d*)/; return $1; }