I have a PDF which is searchable and I need to convert it into a non-searchable one.
I tried using Ghostscript and change it to JPEG and then back to PDF which does the trick but the file size is way too large and not acceptable.
I tried using Ghostscript to convert the PDF to PS first and then PDF which does the trick as well but the quality is not good enough.
gswin32.exe -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pswrite -r1000 -sOutputFile=out.ps in.pdf
gswin32.exe -q -dNOPAUSE -dBATCH -dSAFER -dDEVICEWIDTHPOINTS=596 -dDEVICEHEIGHTPOINTS=834 -dPDFSETTINGS=/ebook -sDEVICE=pdfwrite -sOutputFile=out.pdf out.ps
Is there a way to give a good quality to the PDF?
Alternatively is there an easier way to convert a searchable PDF to a non-searchable one?
Step by Step InstructionsSelect “Edit & Create Profiles” to open Profile Manager. Create a copy of the Non-Searchable PDF system profile. It already creates non-searchable PDF files; we only need to enable the PDF/A compliance option in our copy.
Run Adobe Acrobat. Open scanned PDF with Adobe. Go to Tools>Enhance Scans>Recognize Text>In this File, start processing OCR on the scanned PDF. Once ready, save the searchable PDF file.
Choose Tools > Edit PDF. To turn off automatic OCR, do the following: In the right pane, clear the Recognize text checkbox. From next time, Acrobat won't automatically run OCR.
Normally, you create the file in your software and then "print" it to a PDF printer. This converts the file to PDF format. These PDF files are text-based PDF, meaning that they retain the text and formatting of the original. Text-based PDF files are searchable because they contain real text.
You can use Ghostscript to achieve that. You need 2 steps:
Convert the PDF to a PostScript file, which has all used fonts converted to outline shapes. The key here is the -dNOCACHE
paramenter:
gs -o somepdf.ps -dNOCACHE -sDEVICE=pswrite somepdf.pdf
Convert the PS back to PDF (and, maybe delete the intermediate PS again):
gs -o somepdf-with-outlines.pdf -sDEVICE=pdfwrite somepdf.ps rm somepdf.ps
Note, that the resulting PDF will very likely be larger than the original one. (And, without additional command line parameters, all images in the original PDF will likely also be converted according to Ghostscript builtin defaults, unless you add more command line parameters to do otherwise. But the quality should be better than your own attempt to use Ghostscript...)
Apparently, from version 9.15 (to be released during September/October 2014), Ghostscript will support a new command line parameter:
-dNoOutputFonts
which will cause the output devices pdfwrite
, ps2write
and eps2write
"to 'flatten' glyphs into 'basic' marking operations (rather than writing fonts to the output)".
This means that the above two steps can be avoided, and the desired result be achieved with a single command:
gs -o somepdf-with-outlines.pdf -dNoOutputFonts -sDEVICE=pdfwrite somepdf.pdf
Caveats: I've tested this with a few input files using a self-compiled Ghostscript based on current Git sources. It worked flawlessly in each case.
a possible way to produce non-searchable vector pdf from a searchable vector pdf is
burst pdf in its single pages
pdftk file.pdf burst
convert any single page in svg with
pdftocairo
contained into poppler utils
for f in *.pdf; do pdftocairo -svg $f; done
3 . delete ALL pdf in folder
4 . then, with batikrasterizer
re-convert ALL svg to pdf (this time the resulting pdfs will be kept vectorial, but without to be searchable)
java -jar ./batik-rasterizer.jar -m application/pdf *.svg
final step: join all resulting single page pd in one multipage pdf file
pdftk *.pdf cat output out.pdf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With