Why does the combination pdf2ps / ps2pdf cut PDF?
When you were researching how to compress a bunch of PDFs with pictures inside (ideally lossless, but I'll accept the loss), I found that many people recommend doing this:
$ pdf2ps file.pdf $ ps2pdf file.ps
It works! The resulting file is smaller and looks at least good enough.
- How / why does it work?
- What settings can I configure in this process?
- If there is some kind of lossy conversion what is it?
- Where to catch?
source to share
People who recommend this procedure rarely do it based on experience or knowledge - it is more based on gut feelings.
Avoiding creating a new PDF through PostScript and vice versa (also called "refrying the PDF") will never give you optimal results. This is sometimes useful, i.e. in cases the original PDF was not printed at all or could not be processed by another application. But these cases are very rare.
In any case, this "roundtrip" conversion will never result in the same PDF as originally.
In addition, the tools
all the tools are not independent: it's just a simple shell script command line around Ghostscript (
). You can check it yourself by following these steps:
cat $(which ps2pdf) cat $(which pdf2ps)
This will also show the (default) options that these simple wrappers use for their respective transforms.
If you're out of luck, you will have the ancient Ghostscript installed. The PostScript that is then generated
will be PS level 1, and this will "lose" for many fonts that may be used by more modern PDFs, resulting in rasterization of previous vector fonts. Not exactly the result you would like to look at ...
Since both tools use Ghostscript anyway (but behind your back), you're better off running Ghostscript . This gives you more control over the parameters it uses. Especially advantageous is the fact that in this way you can get a direct PDF-> PDF conversion without any detours through the PostScript proxy format.
Here are some answers that will give you some hints on what options you could use to reduce the semi-controlled file size in your PDF output:
- Optimizing PDF files (with Ghostscript or others) (StackOverflow)
- Remove / remove all images from PDF using Ghostscript or ImageMagick (StackOverflow)
source to share