SBSDKPDFMetadataProcessor
@interface SBSDKPDFMetadataProcessor : NSObject
Enables reading and writing of PDF metadata attributes like author, creator, title, keywords etc. to PDF files. Caution: If you want to use this feature your app must import the PDFKit module.
-
Reads the PDF metadata from a PDF at the given URL.
Declaration
Objective-C
+ (NSDictionary *)readMetadataFrom:(NSURL *)url;
Swift
class func readMetadata(from url: URL!) -> [AnyHashable : Any]!
Parameters
url
The file URL of the PDF to read the metadata from.
Return Value
Returns a dictionary containing the PDF metadata or nil if the metadata could not be extracted from the file. The dictionaries keys are taken from Apple’s PDFKit.framework and can be found here: https://developer.apple.com/documentation/pdfkit/pdfdocumentattribute?language=objc .
-
Extracts the contents of a PDF file and writes a new PDF file along with the given PDF metadata to the specified URL.
Declaration
Objective-C
+ (BOOL)writeMetadata:(NSDictionary *)metadata withPDFFrom:(NSURL *)pdfUrl toURL:(NSURL *)pdfOutput removeCurrentMeta:(BOOL)removeMetadata;
Swift
class func writeMetadata(_ metadata: [AnyHashable : Any]!, withPDFFrom pdfUrl: URL!, to pdfOutput: URL!, removeCurrentMeta removeMetadata: Bool) -> Bool
Parameters
metadata
The PDF metadata dictionary to be written to the output PDF file. The dictionaries keys are taken from Apple’s PDFKit.framework and can be found here: https://developer.apple.com/documentation/pdfkit/pdfdocumentattribute?language=objc .
withPDFFrom
The file URL of the source PDF file.
toURL
The file URL of the destination PDF file.
removeCurrentMeta
If set to YES, the source PDF metadata is ignored. Otherwise both metadata structures will be merged.
Return Value
YES, if the metadata has been successfully saved. NO otherwise.