public interface

DocumentXmpMetadata

com.pspdfkit.document.metadata.DocumentXmpMetadata

Class Overview

This class allows you to modify a PDF documents metadata.

Metadata is defined in two ways in the PDF spec (ยง 14.3): - A metadata stream containing XMP data. This class is handling this. (https://en.wikipedia.org/wiki/Extensible_Metadata_Platform) - The Info PDF dictionary. See DocumentPdfMetadata.

Use getXmpMetadata() to retrieve an instance of this class.

Summary

Constants
String XMP_DC_NAMESPACE Specifies the default Adobe DC namespace
String XMP_DC_NAMESPACE_PREFIX Specifies the default Adobe DC namespace prefix
String XMP_PDF_NAMESPACE Specifies the default Adobe PDF namespace
String XMP_PDF_NAMESPACE_PREFIX Specifies the default Adobe PDF namespace prefix
Public Methods
abstract PdfValue get(String key, String xmlNamespace)
Retrieves a single metadata value from the XMP metadata entries included in the PDF file.
abstract boolean hasUnsavedChanges()
Returns true if there were any changes to the XMP metadata without save.
abstract void set(String key, String value, String namespace, String namespacePrefix)
Sets a single metadata value inside the XMP metadata structure in PDF.

Constants

public static final String XMP_DC_NAMESPACE

Specifies the default Adobe DC namespace

Constant Value: "http://purl.org/dc/elements/1.1/"

public static final String XMP_DC_NAMESPACE_PREFIX

Specifies the default Adobe DC namespace prefix

Constant Value: "dc"

public static final String XMP_PDF_NAMESPACE

Specifies the default Adobe PDF namespace

Constant Value: "http://ns.adobe.com/pdf/1.3/"

public static final String XMP_PDF_NAMESPACE_PREFIX

Specifies the default Adobe PDF namespace prefix

Constant Value: "pdf"

Public Methods

public abstract PdfValue get (String key, String xmlNamespace)

Retrieves a single metadata value from the XMP metadata entries included in the PDF file.

Parameters
key Metadata key, must not be null.
xmlNamespace XML namespace the key belongs to.
Returns
  • a PdfValue instance representing a value or null. In most cases this will be a string, but nested arrays are also possible.

public abstract boolean hasUnsavedChanges ()

Returns true if there were any changes to the XMP metadata without save.

Returns
  • true if XMP metadata was changed, false otherwise.

public abstract void set (String key, String value, String namespace, String namespacePrefix)

Sets a single metadata value inside the XMP metadata structure in PDF. This should be preferred for freeform tags and data instead of modifying the PDF metadata dictionary with set(String, PdfValue).

Parameters
key Key for the metadata entry, must not be null.
value Value for the entry, can be null.
namespace XML namespace to which the entry belongs. For custom data use a custom namespace to avoid collisions with other applications writing the metadata.
namespacePrefix XML namespace prefix/shorthand used in the XML structure. E.g. dc for Adobe DC namespace.