When I execute ps2pdf it does nothing

My task is to bulk convert searchable PDFs into image-only PDFs. I have found out that I can do it with Ghostscript using fist pdf2ps (to convert PDF to PS) and then ps2pdf (to convert PS to PDF).

I installed gs920w32.exe on Windows 10.

pdf2ps works perfectly for me:

pdf2ps "directory\input.pdf" "directory\output.ps"

But ps2pdf simply does nothing:

ps2pdf "directory\output.ps" "directory\output.pdf"

I also noticed that if I execute pdf2ps without parameters, I get

"Usage: pdf2ps [-dASCII85DecodePages=false] [-dLanguageLevel=n] input.pdf output.ps"

But if I execute ps2pfd without paramenets I also get nothing.

What do I do wrong?

UPD: "Image-only" PDF looks the same as "searchable" PDF but you cannot search in it, thus you can also call it just "non-searchable" PDF.

SOLUTION:I solved my problem by executing this:

gswin64c -o "directory\input.pdf" -dNoOutputFonts -sDEVICE=pdfwrite "directory\output.pdf"

2 Answers

The first thing you are doing wrong is expecting this double conversion to produce PDF files which only contain images, it won't. The relevant Ghostscript devices, ps2write and pdfwrite go to considerable lengths to preserve vector information. About the only time you will definitely get an image in the output that wasn't in the input is when the input PDF file contains transparency, because that cannot be preserved into PostScript.

The second thing you are doing wrong is using the scripts. THey are not designed for what you are trying to do. Use the Ghostscript executable instead and write any scripts you need yourself.

Since your (mad) task is to convert a PDF to an image, and then wrap that back up as a PDF, you will want to use one of the Ghostscript rendering devices to render an image for you, and then use one of the view*.ps files to read that image back and write the output through the pdfwrite device.

You won't want to use JPEG as the multiple quantisations will badly affect the image quality. I'd suggest using RAW.

2

I solved my problem by executing this: gswin64c -o "directory\input.pdf" -dNoOutputFonts -sDEVICE=pdfwrite "directory\output.pdf"

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like