I have a need to export to file the FileAttachment type annotations of a pdf.
I am trying to use PDFKit but I cannot find a way to do this.
I'am able to filter annotations of type "FileAttachment" but I can't find any properties or methods that expose them to me in date format so I can save them to file.
I tried inspecting the properties and methods of the individual annotation but could not find the data format
import PDFKit
func filterFileAttachmentAnnotations(in pdfDocument: PDFDocument) -> [PDFAnnotation] {
if let firstPage = pdfDocument.page(at: 0) {
for annotation in firstPage.annotations {
if annotation.type == "FileAttachment" {
// HOWTO?: export fileattachment to user directory
// annotation.contents is nil
// annotation.url is nil
// ...
}
}
}
}