Set custom properties for PDF files in Java

2019-07-23 07:23:21 Written by  support iceblue
Rate this item
(0 votes)

We have already demonstrated how to set PDF Document Properties in Java. This article we will show you how to set custom properties for PDF files in Java.

import com.spire.pdf.*;

public class PDFCustomProperties {
    public static void main(String[] args) throws Exception {

        String inputPath = "Sample.pdf";
        PdfDocument doc = new PdfDocument(inputPath);
        doc.loadFromFile(inputPath);

        //Set the custom properties
        doc.getDocumentInformation().setCustomerDefined("Number", "123");
        doc.getDocumentInformation().setCustomerDefined("Name", "Daisy");
        doc.getDocumentInformation().setCustomerDefined("Company", "e-iceblue");
       
        //Save the document to file
        doc.saveToFile("Output/result.pdf");
        doc.close();

    }
}

Effective screenshot after adding custom properties to PDF document:

Set custom properties for PDF files in Java

Additional Info

  • tutorial_title:
Last modified on Thursday, 02 September 2021 06:18