Working with Document - facades

Get PDF file information - facades

In order to get information specific to PDF file, you need to create an object of PdfFileInfo class. After that, you can get values of the individual properties like Subject, Title, Keywords and Creator etc.

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

Set PDF file information - facades

PdfFileInfo class allows you to set file specific information of a PDF document. You need to create an object of PdfFileInfo class and then set different file specific properties like Author, Title, Keyword, and Creator etc. Finally, save the updated PDF file using saveNewInfo(..) method of the PdfFileInfo object.

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

Get XMP Metadata of an existing PDF File - facades

In order to get XMP metadata from a PDF file, you need to create PdfXmpMetadata object and bind the PDF file using bindPdf(..) method. You can pass specific XMP metadata properties to the PdfXmpMetadata object to get their values.

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

Set XMP Metadata of an existing PDF - facades

In order to set XMP metadata in a PDF file, you need to create PdfXmpMetadata object and bind the PDF file using bindPdf(..) method. You can use setByDefaultMetadataProperties(..) method of the PdfXmpMetadata class to add different properties. Finally, call the save(…) method of PdfXmpMetadata class.

The following code snippet shows you how to add XMP metadata in a PDF file.

Set Viewer Preference of an existing PDF File - facades

The ViewerPreference class represents display modes of PDF files; for example, positioning the document window in the center of the screen, hiding viewer application’s menu bar etc. changeViewerPreference(..) method in PdfContentEditor class allows you to change the viewer preference. In order to do that, you need to create an object of PdfContentEditor class and bind the input PDF file using bindPdf(..) method. Ater that, you can call changeViewerPreference(..) method to set any preferences. Finally, you have to save the updated PDF file using save(..) method.

The following code snippet shows you how to change viewer preference in an existing PDF file.

Adding Javascript actions to existing PDF file

The PdfContentEditor class present under com.aspose.pdf.facades package provides the flexibility to add Javascript actions to a PDF file. You can create a link with the serial actions corresponding to execute a menu item in the PDF viewer. This class also provides the feature to create additional actions for document events.

The following sample code shows you how to add Javascript actions in a PDF file.