PDF File Metadata

Get PDF File Information

To get file-specific information about a PDF file, first get the DocumentInfo object using the Document class’¬†getInfo(). Once the DocumentInfo object is retrieved, you can get the values of the individual properties.

The following code snippet shows you how to set PDF file information.

Set PDF File Information

Aspose.PDF for Java allows you to set file-specific information for a PDF, information like author, creation date, subject, and title.

To set this information:

  1. Create a DocumentInfo object.
  2. Set the values of the properties.
  3. Save the updated document using the Document class’ save() method.

The following code snippet shows you how to set PDF file information.

Get XMP Metadata from PDF File

Aspose.PDF for Java allows you to access a PDF file’s XMP metadata.

To get a PDF file’s metadata,

  1. Create a Document object and open the input PDF file.
  2. Use the getMetadata() property to get the metadata.

The following code snippet shows you how to get metadata from the PDF file.

Remove Metadata from PDF

Aspose.PDF for Java allows you to add, update, and remove metadata from PDF documents.

To remove metadata:

  1. Create a Document object.
  2. Check if the particular property exists in the PDF file.
  3. If it exists, use the removeItem(..) method to remove it.
  4. Save the updated document using the Document object’s Save method.

The following code snippet shows you how to remove metadata from a PDF file.

You cannot remove the pdf:Producer, xmp:ModifyDate, xmp:CreatorTool, or xmp:MetadataDate properties as they are required. All other properties can easily be removed.