Set PDF Document Properties in Java

In this article, we're going to demonstrate how to set PDF document properties, such as title, author, subject, key words, creation date, creator and producer, using Spire.PDF for Java.

import com.spire.pdf.PdfDocument;

import java.util.Date;

public class SetDocumentProperties {
    public static void main(String[] args)
        //Instantiate a PdfDocument instance
        PdfDocument pdf = new PdfDocument();
        //Load the PDF document

        //Set title
        pdf.getDocumentInformation().setTitle("Spire.PDF for Java Demo");
        //Set author
        pdf.getDocumentInformation().setAuthor("Spire Team");
        //Set subject
        pdf.getDocumentInformation().setSubject("Document Properties Setting");
        //Set key words
        pdf.getDocumentInformation().setKeywords("Document Properties, Spire.PDF");
        //Set creation date
        pdf.getDocumentInformation().setCreationDate(new Date());
        //set creator
        pdf.getDocumentInformation().setCreator("Spire.PDF for Java");
        //set producer
        pdf.getDocumentInformation().setProducer("Spire.PDF for Java");

        //save the document

Set PDF Document Properties in Java