Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Some of the size optimizations that you observed may come from Ghostscript's cleaning up of unused objects, its recently acquired font optimization improvements (do you use a very recent version of GS?!?) and possibly image re-/down-sampling that may have happened.</p> <p>Ghostscript, if used for <em>PDF -> PDF</em> conversions, basically operates like this:</p> <ol> <li>Read in the input file(s) with all its objects and convert them into its internal format for graphical page representations.</li> <li>Do the manipulations <em>asked for on the commandline</em> to the page contents in the internal format.</li> <li>Write out a completely new PDF.</li> </ol> <p>This means that for most <em>PDF -> PDF</em> operations you'll have different ordering and numbering for the PDF objects, and even the object's internal code may have changed (even if your eyes don't discover any differences between input and output PDF).</p> <p>By default Ghostscript also will compress any object streams that have been uncompressed in the original file (but this is a lossless compression).</p> <p>Now for your very simplistic commandline <em>which does not contain any wishes for manipulations</em>, Ghostscript <em>assumes</em> you want to use <code>-dPDFSETTINGS=/default</code>, sets this parameter implicitly and operates accordingly.</p> <p>Now <em>what</em> are the <code>/default</code> PDFSETTINGS?! You have two options to find out:</p> <ol> <li><p><strong>Read the manual</strong>. The large <a href="http://git.ghostscript.com/?p=ghostpdl.git;a=blob_plain;f=gs/doc/Ps2pdf.htm;hb=master#Options" rel="nofollow noreferrer"><strong>table in middle of this section</strong></a> gives an overview. You can see that this one <code>-dPDFSETTINGS=/default</code> in itself is just a shorthand for the several dozen other more specific settings which it represents. The link to the documentation given is for current HEAD of the development code <strong>and your actually used version may be different of course</strong>.</p></li> <li><p><strong>Query (your own) Ghostscript for the detailed meaning of this setting.</strong> My answers to question <a href="https://stackoverflow.com/a/11002313/359307"><strong>'Querying Ghostscript for the default options/settings of an output device...'</strong></a> and question <a href="https://stackoverflow.com/a/11139870/359307"><strong>'What are PostScript dictionaries, and how can they be accessed (via Ghostscript)?'</strong></a> do elaborate a bit more on this. In short, to query Ghostscript for the details of its <code>/default</code> PDFSETTINGS, run this command:</p> <pre><code> gs \ -q \ -dNODISPLAY \ -c ".distillersettings /default get {exch ==only ( ) print ===} forall quit" </code></pre> <p>You should get a result very similar to this:</p> <pre><code> /Optimize false /DoThumbnails false /PreserveEPSInfo true /ColorConversionStrategy /LeaveColorUnchanged /DownsampleMonoImages false /EmbedAllFonts true /CannotEmbedFontPolicy /Warning /PreserveOPIComments true /GrayACSImageDict &lt;&lt; /HSamples [2 1 1 2] /VSamples [2 1 1 2] /QFactor 0.9 /Blend 1 &gt;&gt; /DownsampleColorImages false /PreserveOverprintSettings true /CreateJobTicket false /AutoRotatePages /PageByPage /NeverEmbed [/Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique /Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique /Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic /Symbol /ZapfDingbats] /ColorACSImageDict &lt;&lt; /HSamples [2 1 1 2] /VSamples [2 1 1 2] /QFactor 0.9 /Blend 1 &gt;&gt; /DownsampleGrayImages false /UCRandBGInfo /Preserve </code></pre> <p>The only point that stands out from these: you may want to change <code>/AutoRotagePages</code> from <code>/PageByPage</code> to <code>/None</code>. On the commandline you would put it as <code>-dAutoRotatePages=/None</code>.</p> <p>To give you a complete list of parameters which would specifically tell Ghostscript to employ as much of a <em>passthrough</em> mode as it possibly can to the input PDF by adding these parameters:</p> <pre><code> -dAntiAliasColorImage=false \ -dAntiAliasGrayImage=false \ -dAntiAliasMonoImage=false \ -dAutoFilterColorImages=false \ -dAutoFilterGrayImages=false \ -dDownsampleColorImages=false \ -dDownsampleGrayImages=false \ -dDownsampleMonoImages=false \ -dColorConversionStrategy=/LeaveColorUnchanged \ -dConvertCMYKImagesToRGB=false \ -dConvertImagesToIndexed=false \ -dUCRandBGInfo=/Preserve \ -dPreserveHalftoneInfo=true \ -dPreserveOPIComments=true \ -dPreserveOverprintSettings=true \ </code></pre></li> </ol> <p>So you could try this command:</p> <pre><code>gs \ -o output.pdf \ -sDEVICE=pdfwrite \ -dAntiAliasColorImage=false \ -dAntiAliasGrayImage=false \ -dAntiAliasMonoImage=false \ -dAutoFilterColorImages=false \ -dAutoFilterGrayImages=false \ -dDownsampleColorImages=false \ -dDownsampleGrayImages=false \ -dDownsampleMonoImages=false \ -dColorConversionStrategy=/LeaveColorUnchanged \ -dConvertCMYKImagesToRGB=false \ -dConvertImagesToIndexed=false \ -dUCRandBGInfo=/Preserve \ -dPreserveHalftoneInfo=true \ -dPreserveOPIComments=true \ -dPreserveOverprintSettings=true \ input1.pdf \ input2.pdf </code></pre> <p><strong>Finally</strong>, as Chris Haas already hinted at: you can also use <code>pdftk</code> if you <em>specifically do not want any of the optimizations</em> that Ghostscript applies by default. <code>pdftk</code> is simply unable to do such things, and you'll gain quite a bit of speed for its relative dumbness of operation (but probably also much larger file size outputs than from Ghostscript). </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload