From ab3baae5ea925c50a7d3bc5fe1ee1b809770f066 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Fri, 20 Jan 2012 18:41:01 +0100 Subject: pswrite -> ps2write; preserve image quality in PDFs --- pdftool.pl | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/pdftool.pl b/pdftool.pl index ca9f2a5..fd8e4c7 100755 --- a/pdftool.pl +++ b/pdftool.pl @@ -52,7 +52,7 @@ is I. If no output file is given, or if a single hyphen-minus (I<->) is given as file name, B sends the data to the standard output. By -default, B outputs a PDF document; see B<--ps> to +default, B outputs a PDF document; Use B<--ps> to get a PostScript instead. B does the following passes on the input document: @@ -182,9 +182,6 @@ on your screen. By default, B outputs a PDF document; use this flag if you want a PostScript instead. -Note that due to a L of C with -the C device, the PostScript output might not be suitable for uses other than printing. - =item B<--column> @@ -531,8 +528,7 @@ sub pdftops { } # Convert to PS - # TODO: use gs & pswrite the day it'll handle fonts properly - # (the flag `-origpagesizes' seems not to be portable) + # TODO: use gs & ps2write, more portable my @cmd = ('pdftops', '-origpagesizes', $infile, '-'); push @cmd, '-f', $first if defined $first; push @cmd, '-l', $last if defined $last; @@ -851,11 +847,18 @@ sub pswrite { $pagedevice = "/PageSize [$outwidth $outheight]"; } - my @device = ('-sDEVICE=pdfwrite'); - @device = ('-sDEVICE=pswrite', '-dLanguageLevel=3') - if defined $psout; - my @cmd = (@gs, @device, '-dQUIET', '-dBATCH', '-dNOPAUSE', - '-sOutputFile=%stdout%', '-dAutoRotatePages=/None', + my $device = '-sDEVICE=pdfwrite'; + $device = '-sDEVICE=ps2write' if defined $psout; + my @cmd = (@gs, '-dQUIET', '-dBATCH', '-dNOPAUSE', $device, + '-dAutoRotatePages=/None', + '-dDetectDuplicateImages=false', + # Preserve image quality + '-dAutoFilterColorImages=false', + '-dAutoFilterGrayImages=false', + '-dColorImageFilter=/FlateEncode', + '-dGrayImageFilter=/FlateEncode', + '-dMonoImageFilter=/FlateEncode', + '-sOutputFile=%stdout%', '-c', "<< $pagedevice >> setpagedevice", '-f', '-'); -- cgit v1.2.3