PSPDFDocumentXMPMetadata


@interface PSPDFDocumentXMPMetadata : NSObject

This class allows you to modify a PDF documents 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.

  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFDocumentXMPMetadata : NSObject
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFDocumentXMPMetadata : NSObject
  • Initializes the PSPDFDocumentXMPMetadata with a document. The document needs to be valid. If its 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

    - (nonnull 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 (readonly, nonatomic) PSPDFDocument *_Nonnull document;

    Swift

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

    Declaration

    Objective-C

    @property (readonly, nonatomic) 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.