How to Add Title, Author, Subject and keywords to the Pdf document using iText

We can extend itext to add Title for the Pdf document, we can add Author name, subject and also keywords to the pdf document.

You can view these details in Pdf File -> Properties.

We will extend the basic example and demonstrate this example:

We can see the different options that are available to extend the use of iText pdf.

Enter document. and press space bar, where it will show you the options like below :
itext document proposal options

Please find the below example program:

import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;

public class iTextPDFTutorial {
	public void iTextPDF() throws Exception{
		String FILE = "D:/sampleiTextexample.pdf";
		Document document = new Document();
			new FileOutputStream(FILE));;
		//To add the title to PDF
		document.addTitle("iText Pdf");//
		//To add the Author for the PDF
		document.addAuthor("Selenium Easy");
		//To add the subject to the PDF document
		document.addSubject("iText Tutorial");
		//To add the Keywords for the document
		document.add(new Paragraph("Hello iText advanced example "));
		document.add(new Paragraph("Please check the properties of the PDF"));
	public static void main(String args[]){
		iTextPDFTutorial get = new iTextPDFTutorial();
		try {
		} catch (Exception e) {

The below is the output report generated:
itext document proposal options

Reporting Tools: 

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.