How to add password protection to PDF using iText in Java?

The PdfWriter class provides the setEncryption() method to set the password protection on a pdf file. Syntax: public void setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType) throws DocumentException. 1. userPassword – It specify the user password. 2. ownerPassword – It specify the owner password. 3. permissions – It specify the user permissions. 4. encryptionType … Read more

How to modify an existing pdf file in java using iText jar?

To modify an existing pdf file using iText jar first download the iText jar files and include in the application classpath. Steps: 1. Create PdfReader instance. 2. Create PdfStamper instance. 3. Create BaseFont instance. 4. Get the number of pages in pdf. 5. Iterate the pdf through pages. 6. Contain the pdf data using PdfContentByte. … Read more

How to merge two pdf files using itext in java?

To merge two or more pdf file using iText jar first download the iText jar files and include in the application classpath. Steps: 1. Prepare input pdf file list as list of input stream. 2. Prepare output stream for merged pdf file. 3. call method to merge pdf files. 4. Create document and pdfReader objects. … Read more

How to split an existing pdf file using iText jar in Java?

To split a pdf file using iText jar first download the iText jar files and include in the application classpath. Steps: 1. Prepare output stream for new pdf file after split process. 2. Call method to split pdf file. 3. Create document and pdfReader objects. 4. Get total no. of pages in the pdf file. … Read more

How to read an existing pdf file in java using iText jar?

To read an existing pdf file using iText jar first download the iText jar files and include in the application classpath. Steps: 1. Create PdfReader instance. 2. Get the number of pages in pdf 3. Iterate the pdf through pages. 4. Extract the page content using PdfTextExtractor. 5. Process the page content on console. 6. … Read more

java iText chapter and section

Java iText chapter: The Chapter is used to add the chapter in the pdf file. It is represented by com.itextpdf.text.Chapter class. Java iText Section: The Section is used to add the section in the pdf file. It is represented by com.itextpdf.text.Section class. Steps: 1. Create Document instance. It represents the current document to which we … Read more

java iText font

The Font class object is used to specify the font style of the text. It is represented by com.itextpdf.text.Font class. Steps: 1. Create Document instance. It represents the current document to which we are adding content. 2. Create OutputStream instance. It represents the generated pdf. 3. Create PDFWriter instance and pass Document and OutputStream instance … Read more

java iText image

The Image class object is used to add the image in the pdf file. We can specify the image properties like position, alignment, border etc. It is represented by com.itextpdf.text.Image class. Steps: 1. Create Document instance. It represents the current document to which we are adding content. 2. Create OutputStream instance. It represents the generated … Read more

java iText table

The Table is used to add the table in the pdf file. We have to define the number of columns in the PdfTable constructor. It is represented by com.itextpdf.text.PdfPTable class. Steps: 1. Create Document instance. It represents the current document to which we are adding content. 2. Create OutputStream instance. It represents the generated pdf. … Read more

java iText list

The List represents a list of items and can be ordered or unordered. It is represented by com.itextpdf.text.List class. Steps: 1. Create Document instance. It represents the current document to which we are adding content. 2. Create OutputStream instance. It represents the generated pdf. 3. Create PDFWriter instance and pass Document and OutputStream instance to … Read more