Bug 694099 - pdfopt is missing in ghostscript-9.07
Summary: pdfopt is missing in ghostscript-9.07
Status: RESOLVED WONTFIX
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Build Process (show other bugs)
Version: 9.07
Hardware: PC Linux
: P4 normal
Assignee: Chris Liddell (chrisl)
QA Contact: Bug traffic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-23 19:47 UTC by Thomas Dreibholz
Modified: 2013-06-26 01:19 UTC (History)
3 users (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Dreibholz 2013-05-23 19:47:37 UTC
pdfopt seems to be missing in the ghostscript-9.07 package. There are only the manpages in the build directory:

/tmp/ghostscript-9.07$ make
/tmp/ghostscript-9.07$ find -name "*pdfopt*"
./man/de/pdfopt.1
./man/pdfopt.1

Also, pdfopt is missing in the corresponding Ubuntu package (Bug #1173876: https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/1173876). Probably -- but I did not check -- it is then also missing in Debian as well.
Comment 1 Ken Sharp 2013-05-23 19:56:10 UTC
(In reply to comment #0)
> pdfopt seems to be missing in the ghostscript-9.07 package. There are only
> the manpages in the build directory:
> 
> /tmp/ghostscript-9.07$ make
> /tmp/ghostscript-9.07$ find -name "*pdfopt*"
> ./man/de/pdfopt.1
> ./man/pdfopt.1
> 
> Also, pdfopt is missing in the corresponding Ubuntu package (Bug #1173876:
> https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/1173876).
> Probably -- but I did not check -- it is then also missing in Debian as well.

pdfopt is deprecated as the pdfwrite device can now manufacture linearised (optimised for fast web viewing) PDF files directly. We are not responsible for the man pages.....
Comment 2 jsmeix 2013-05-24 08:13:38 UTC
FYI:
Regarding "We are not responsible for the man pages" see
http://bugs.ghostscript.com/show_bug.cgi?id=693644
Comment 3 Ken Sharp 2013-05-24 08:21:26 UTC
(In reply to comment #2)
> FYI:
> Regarding "We are not responsible for the man pages" see
> http://bugs.ghostscript.com/show_bug.cgi?id=693644

I stand corrected. Nevertheless this is not a bug.
Comment 4 wmstrome 2013-06-25 10:54:21 UTC
(In reply to comment #1)
> (In reply to comment #0)
> 
> pdfopt is deprecated as the pdfwrite device can now manufacture linearised
> (optimised for fast web viewing) PDF files directly. We are not responsible
> for the man pages.....

I have been using a python script (compress-newsletter.pl  http://wiki.scribus.net/canvas/Web_optimised_PDF) which no longer works because it uses pdfopt. It is not clear to me how I should change this script in view of the statement:

"pdfopt is deprecated as the pdfwrite device can now manufacture linearised (optimised for fast web viewing) PDF files directly."
Comment 5 Ken Sharp 2013-06-25 12:05:27 UTC
(In reply to comment #4)
> (In reply to comment #1)
> > (In reply to comment #0)
> > 
> > pdfopt is deprecated as the pdfwrite device can now manufacture linearised
> > (optimised for fast web viewing) PDF files directly. We are not responsible
> > for the man pages.....
> 
> I have been using a python script (compress-newsletter.pl 
> http://wiki.scribus.net/canvas/Web_optimised_PDF) which no longer works
> because it uses pdfopt. It is not clear to me how I should change this
> script in view of the statement:
> 
> "pdfopt is deprecated as the pdfwrite device can now manufacture linearised
> (optimised for fast web viewing) PDF files directly."

Nothing stops you using the existing pdfopt PostScript program, it works as well as it ever did (ie badly). However we won't continue to distribute it, nor fix bugs in it.

To be perfectly honest, there is no real point in producing a web-optimised PDF file, and files using the features of more recent versions of PDF (Cross reference streams, introduced in PDF 1.5 ten years ago) cannot be made into 'web optimised' files at all as tehse are incompatible with the Linearised PDF specification.

However, if you still want to produce a Linearised PDF using Ghostscript, then you will have to pass the PDF file through Ghostscript, writing to the pdfwrite device, and specifying -dFastWebView. Of course this assumes that you are producing the PDF file from some source other than Ghostscript in the first place. If you are producing the original PDF file using Ghostscript then just supply the -dFastWebView switch and the file will be produced Linearised.
Comment 6 wmstrome 2013-06-25 13:39:03 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #1)
> > > (In reply to comment #0)
> > > 
> > > pdfopt is deprecated as the pdfwrite device can now manufacture linearised
> > > (optimised for fast web viewing) PDF files directly. We are not responsible
> > > for the man pages.....
> > 
> > I have been using a python script (compress-newsletter.pl 
> > http://wiki.scribus.net/canvas/Web_optimised_PDF) which no longer works
> > because it uses pdfopt. It is not clear to me how I should change this
> > script in view of the statement:
> > 
> > "pdfopt is deprecated as the pdfwrite device can now manufacture linearised
> > (optimised for fast web viewing) PDF files directly."
> 
> Nothing stops you using the existing pdfopt PostScript program, it works as
> well as it ever did (ie badly). However we won't continue to distribute it,
> nor fix bugs in it.
> 
> To be perfectly honest, there is no real point in producing a web-optimised
> PDF file, and files using the features of more recent versions of PDF (Cross
> reference streams, introduced in PDF 1.5 ten years ago) cannot be made into
> 'web optimised' files at all as tehse are incompatible with the Linearised
> PDF specification.
> 
> However, if you still want to produce a Linearised PDF using Ghostscript,
> then you will have to pass the PDF file through Ghostscript, writing to the
> pdfwrite device, and specifying -dFastWebView. Of course this assumes that
> you are producing the PDF file from some source other than Ghostscript in
> the first place. If you are producing the original PDF file using
> Ghostscript then just supply the -dFastWebView switch and the file will be
> produced Linearised.

I am not really a programmer (I used to be many decades ago), so I just want to know how to modify the compress-newsletter.pl script so that it will work using the current version of ghostscript, which does NOT contain pdfopt. The work-around I used was to simply convert the pdf file to ps using pdftops the converting it back to pdf using:
ps2pdf -dEmbedAllFonts=true -dUseFlateCompression=true

I don't think this compressed the file quite as much as the
compress-newsletter.pl did, however. It did make a manageable sized pdf.

The reason I need this is not for web optimization. Rather, Scribus creates really HUGE pdf files, which are too big to conveniently E-Mail or upload to printers for printing. The python script typically compressed such files by a factor of 10-15 or even more.  I use Scribus a lot.
Comment 7 Ken Sharp 2013-06-25 14:59:04 UTC
(In reply to comment #6)

> I am not really a programmer (I used to be many decades ago), so I just want
> to know how to modify the compress-newsletter.pl script so that it will work
> using the current version of ghostscript, which does NOT contain pdfopt.

Bluntly, I have no idea, its not our script so I have no clue what its contents are. Even if I had the script I don't speak Perl. Also, as I said before, the fact that we no longer ship pdfopt.ps doesn't preclude you copying it from an earlier release and using it, it will work as well as it ever did.


> The
> work-around I used was to simply convert the pdf file to ps using pdftops
> the converting it back to pdf using:
> ps2pdf -dEmbedAllFonts=true -dUseFlateCompression=true

Why do a 2-step process ? You can convert PDF directly to PDF, after all Ghostscript can read a PDF file as well as it can a PostScript file.


> The reason I need this is not for web optimization. Rather, Scribus creates
> really HUGE pdf files, which are too big to conveniently E-Mail or upload to
> printers for printing. The python script typically compressed such files by
> a factor of 10-15 or even more.  I use Scribus a lot.

Then don't use web optimisation, that just makes files *bigger*. Just pass them through Ghostscript using the pdfwrite device and they 'may' get smaller. No guarantees, as that's not what pdfwrite is for.

Note that pdfopt certainly would not make files smaller, so most likely you can simply remove that step from your script, whatever it is/was doing, the pdfopt step would not result in smaller files.
Comment 8 Hin-Tak Leung 2013-06-26 01:19:34 UTC
(In reply to comment #6)
...
> I am not really a programmer (I used to be many decades ago), so I just want
> to know how to modify the compress-newsletter.pl script so that it will work
> using the current version of ghostscript...

Here is an untested procedure:

----- Before "## 0. ..."
replace

     my $tmpfile = mktemp("${root}.tmp_XXXXXX");

with 

     my $tmpfile = $outfile;

---- a bit after "## 2. ..."
Insert

     push @gsargs, '-dFastWebView=true';

somewhere among those "push ..." lines. You might want to try beginning, end, middle for best results.

---- near "## 3. ..."

remove the entire block of:
   
    ## 3. Run pdfopt
    print "Running pdfopt ...\n";
    print STDERR "$pdfopt @pdfoptargs $tmpfile $outfile\n" if ($debug);
    system($pdfopt,@pdfoptargs,$tmpfile,$outfile);

also change a little further down:
        foreach my $file ($psfile,$tmpfile) {
to      
        foreach my $file ($psfile) {

===============================================================
On 2nd thought, a somewhat simplier but uglier/barbaric way of modifying the script to achieve what you what is just to make pdfopt into either ps2pdf (re-distilling, waste CPU cycles), or just copy (since pdfwrite is supposed to have done the job).

So an alternative suggestion is to *only* do "## 2..." above (none of the other steps!), and replace the line:

    my ($pdfopt,  @pdfoptargs ) = ('pdfopt' );
by
    my ($pdfopt,  @pdfoptargs ) = ('cp' );
*or*
    my ($pdfopt,  @pdfoptargs ) = ('ps2pdf' );

YMMV.