In this program we are going to change the version of
pdf file through java program.
In this example we need iText.jar file, without this jar file we never compile our application . The package we need to import is java.io.FileOutputStream, java.io.IOException, com.lowagie.text.Document, com.lowagie.text.DocumentException, com.lowagie.text.Paragraph, com.lowagie.text.Rectangle,com.lowagie.text.pdf.PdfWriter, import com.lowagie.text.pdf.PdfReader
The java.io.FileOutputStream and java.io.IOException classes are used to create file and throw the exception, if there is any exception occurs while creating a file. The com.lowagie.text.Document class is used to create a document object, com.lowagie.text.DocumentException is used to throw exception if there is any exception. com.lowagie.text.Paragraph classes is used to make paragraph , com.lowagie.text.Rectangle classes is used to create object of Rectangle class which will be used for setting the left, right, top, bottom margin, com.lowagie.text.pdf.PdfWriter class is used to write the document on a pdf file,com.lowagie.text.pdf.PdfReader class provide a getPdfVersion() method which used to find the version of pdf file.
To make the program for changing the pdf version firstly we will make a class ChaningVersionPDF. Remember the name of the file should be such that, if any other person sees the example then just by seeing the name of the program he can understand what the program is going to do without seeing the code.
Inside this class declare the main method which must throws Exception. After that follow the simple steps find the version:
The code of the program is given below:
The output of the program is given below:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.