How to transfer an arbitrary PDF file to PDF-1.2?

I have custom PDF files. Files are usually created using Word, but they can simply be any valid PDF files. I would like to convert the file to PDF-1.2 if they have a higher version number. Functions that are available only in a higher version (for example, in multimedia) should be removed, and the result should be reasonably reasonable and readable.

How to do this programmatically, without interactive tools like Adobe Acrobat? Preferably with Java and iText -library, but I will be interested in other solutions too.

One way would be to create a bunch of images from the original PDF and then pack them as a PDF-1.2 file, but is this a more elegant way?

+4
source share
3 answers

Try the command below. It uses Ghostscript to relocate the PDF. Use Ghostscript version 8.71 or later: 9.00. (The incorrectly protested answer above to "install the PDF version on iText using setPdfVersion ()" will NOT work - it only rewrites the PDF file, which will only be incorrect ...)

gswin32c.exe ^ -o output-v1.2.pdf ^ -sDEVICE=pdfwrite ^ -dPDFSETTINGS=/ebook ^ -dCompatibilityLevel=1.2 ^ input-v1.6.pdf 
+2
source

The easiest way is to retype it through Ghostscript.

+1
source

You can install the PDF version in iText using setPdfVersion () , however downgrading will not work out of the box, I think. You can use PdfCopy and write your pdf files to a new one with version 1.2 and cut all 1.2 objects. Or convert them to objects of version 1.2 (which you have to do yourself, I think, not sure, however)

+1
source

Source: https://habr.com/ru/post/1334640/


All Articles