简体   繁体   中英

How to set pdf version of existing PDF in IText 7?

How can I change the pdf version of an existing PDF Document in IText 7?

Only the WriterProperties object has the setPdfVersion(version) function. But how do I use this on my PdfReader document, or on the PdfDocument ? I am using Java.

Ok what you have to do is:

WriterProperties wp = new WriterProperties();
wp.setPdfVersion(PdfVersion.PDF_1_X);//X needs to be replaces for the version you want
PdfDocument pdfDoc = new PdfDocument(new PdfReader("orig.pdf"), new PdfWriter("dest.pdf", wp));
pdfDoc.close();

Setting the PDF version using setPdfVersion does not conform the new PDF to the set PDF level specified. For example, if you start with a PDF version 1.7, set the PDF version to 1.4 and the PDF has layers; the resulting PDF will still have layers and not meet the 1.4 specification.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM