Friday, December 30, 2011

Can change the version of the PDF? "YES"

Can we change the version of our PDF?

Definitely "YES"...
With the use of PdfReader class in iText, we can easily change the version of the PDF file.

For Older version supports in some functionalities in proper alignment. But in our new version, Sometimes it does not hear our commands... At that time we can use the following for changing the pdf version...

PdfWriter.getInstance(doc1, new FileOutputStream("D:\\pdf\\pdf1.pdf"));
doc1.open();
doc1.add(new Paragraph("For checking Version"));
doc1.close();
PdfReader reader1 = new PdfReader("D:\\pdf\\pdf1.pdf");
System.out.println("Version of PDF1:"+reader1.getPdfVersion());
char str1=reader1.getPdfVersion();
PdfWriter writer=PdfWriter.getInstance(doc, new FileOutputStream("D:\\pdf\\pdf2.pdf"));
writer.setPdfVersion(PdfWriter.VERSION_1_2);
doc.open();
doc.add(new Paragraph("Version Of PDF1-->>"+str1));
doc.close();
PdfReader reader = new PdfReader("D:\\pdf\\pdf2.pdf");
System.out.println("Version of PDF2:"+reader.getPdfVersion());

No comments:

Post a Comment