PSPDFDocumentXMPMetadata

Objective-C


@interface PSPDFDocumentXMPMetadata : NSObject

Swift

class XMPMetadata : NSObject

This class allows you to modify a PDF document’s metadata. Metadata is defined in two ways in the PDF spec (§ 14.3):

XMP support

This class implements limited XMP support. You can only set and retrieve simple strings.

Namespaces

Each key in the XMP metadata stream has to have a namespace set. You can define your own namespace or use one of the already existing ones. PSPDFKit exposes two constants for common namespaces:

When setting a value, you also have to pass along a suggested namespace prefix, as this can’t be automatically generated.

  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Initializes the PSPDFDocumentXMPMetadata with a document. The document needs to be valid. If it is not, reading or setting values will fail gracefully.

    Note

    If document is a compound document, this will provide access to ONLY the first PSPDFDocumentProvider.

    Declaration

    Objective-C

    - (nullable instancetype)initWithDocument:(nonnull PSPDFDocument *)document;

    Swift

    convenience init?(document: PSPDFDocument)
  • Initializes the PSPDFDocumentXMPMetadata with a document provider.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithDocumentProvider:
        (nonnull PSPDFDocumentProvider *)documentProvider;

    Swift

    init(documentProvider: PSPDFDocumentProvider)
  • Provides access to the document this instance is handling.

    Declaration

    Objective-C

    @property (nonatomic, readonly) PSPDFDocument *_Nonnull document;

    Swift

    var document: PSPDFDocument { get }
  • Provides access to the document provider this instance is handling.

    Declaration

    Objective-C

    @property (nonatomic, readonly) PSPDFDocumentProvider *_Nonnull documentProvider;

    Swift

    var documentProvider: PSPDFDocumentProvider { get }
  • Returns the string that is set in the XMP metadata stream for the given namespace and key.

    Declaration

    Objective-C

    - (nullable NSString *)stringForXMPKey:(nonnull NSString *)key
                                 namespace:(nonnull NSString *)ns;

    Swift

    func string(forXMPKey key: String, namespace ns: String) -> String?
  • Sets the given string for the given XMP key.

    Declaration

    Objective-C

    - (void)setString:(nullable NSString *)string
                       forXMPKey:(nonnull NSString *)key
                       namespace:(nonnull NSString *)ns
        suggestedNamespacePrefix:(nonnull NSString *)nsPrefix;

    Swift

    func setString(_ string: String?, forXMPKey key: String, namespace ns: String, suggestedNamespacePrefix nsPrefix: String)

    Parameters

    string

    The string you want to set.

    key

    The key in the XMP top level dictionary.

    ns

    The namespace you want to use.

    nsPrefix

    The suggested namespace prefix for the namespace.