PSPDFDocumentPDFMetadata
Objective-C
@interface PSPDFDocumentPDFMetadata : NSObject
Swift
class PDFMetadata : NSObject
This class allows you to modify a PDF document’s metadata. Metadata is defined in two ways in the PDF spec (§ 14.3):
- The Info PDF dictionary. This class is handling this.
- A metadata stream containing XMP data. See
PSPDFDocumentXMPMetadata
for that. (https://en.wikipedia.org/wiki/Extensible_Metadata_Platform)
Info dictionary support
All values specified in the Info dictionary are represented by the following types:
NSString
NSNumber
NSDate
NSArray<id>
: can include any of the types mentioned.NSDictionary<NSString*, id>
: value can be any of the types mentioned.
These types can be combined in any way you see fit and it will be converted into the proper PDF types.
Note
The PDF stream type is not yet supported.-
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
PSPDFDocumentPDFMetadata
with a document. The document needs to be valid. If it is not, reading or setting values will fail gracefully.Note
Ifdocument
is a compound document, this will provide access to ONLY the firstPSPDFDocumentProvider
.Declaration
Objective-C
- (nullable instancetype)initWithDocument:(nonnull PSPDFDocument *)document;
Swift
convenience init?(document: PSPDFDocument)
-
Initializes the
PSPDFDocumentPDFMetadata
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, weak, readonly) PSPDFDocument *_Nullable document;
Swift
weak 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 a list of all the keys set in the
Info
dictionary.Declaration
Objective-C
@property (nonatomic, readonly) NSArray<PSPDFMetadataName> *_Nonnull allInfoKeys;
Swift
var allInfoKeys: [PDFMetadata.Key] { get }
-
Returns the object that is set in the
Info
dictionary forkey
Note
Please see the class documentation for types that might be returned.Declaration
Objective-C
- (nullable id)objectForInfoDictionaryKey:(nonnull PSPDFMetadataName)key;
Swift
func object(forInfoDictionaryKey key: PDFMetadata.Key) -> Any?
-
Sets the given object in the
Info
dictionary forkey
.Note
Please see the class documentation for valid types forvalue
. If you pass a invalid type, a exception will be raised.Declaration
Objective-C
- (void)setObject:(nullable id)object forInfoDictionaryKey:(nonnull PSPDFMetadataName)key;
Swift
func setObject(_ object: Any?, forInfoDictionaryKey key: PDFMetadata.Key)
-
Allows generic dictionary access.
Declaration
Objective-C
- (nullable id)objectForKeyedSubscript:(nonnull PSPDFMetadataName)key;
Swift
subscript(key: PDFMetadata.Key) -> Any? { get set }
-
Allows generic dictionary access.
Declaration
Objective-C
- (void)setObject:(nullable id)object forKeyedSubscript:(nonnull PSPDFMetadataName)key;