What's new in PDFKit

RSS for tag

Discuss the WWDC22 Session What's new in PDFKit

Posts under wwdc2022-10089 tag

11 Posts

Post

Replies

Boosts

Views

Activity

How to use PDFPageOverlayViewProvider?
I'm trying to use PDFPageOverlayViewProvider by copying the code provided in the "What's new in PDFKit" WWDC22 session here: https://developer.apple.com/videos/play/wwdc2022/10089/ I've copied the method implementations and set my pdfView's pageOverlayViewProvider property to the view where I implemented the protocol. However, when I try to run my app, the pdfView(_ view: PDFView, overlayViewFor page: PDFPage) method is never getting called. Has anyone been able to get this working successfully?
5
1
3.9k
Jul ’23
Codes are not working at this video.
https://developer.apple.com/videos/play/wwdc2022/10089/ I am trying to run codes about PDFPageOverlayViewProvider, but the codes are not working. I cannot see what I wrote or annotate. Anyone know how can I solve and make this code working?  func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? {         var resultView: PKCanvasView? = nil         if let overlayView = pageToViewMapping[page] {             resultView = (overlayView as! PKCanvasView)         } else {             let canvasView = PKCanvasView(frame: .zero)             canvasView.drawingPolicy = .anyInput             canvasView.tool = PKInkingTool(.pen, color: .yellow, width: 20)             canvasView.backgroundColor = .clear             pageToViewMapping[page] = canvasView             resultView = canvasView         }         let page = page as! WatermarkPage         if let drawing = page.drawing {             resultView?.drawing = drawing         }         return resultView     }          func pdfView(_ pdfView: PDFView, willEndDisplayingOverlayView overlayView: UIView, for page: PDFPage) {         let overlayView = overlayView as! PKCanvasView         let page = page as! WatermarkPage         page.drawing = overlayView.drawing         pageToViewMapping.removeValue(forKey: page)     }
2
0
1.2k
Jul ’23
PDFKit PencilKit annotations sample code
Hello, I was wondering if the sample code shown in Session 10089 of WWDC22 could be made available? To be more specific, I am interested in overlaying a PencilKit PKCanvasView over a PDFKit PDFView. I can't seem to get the PKCanvasView to recognize touch events. This isn't really covered in the session, and I can't get it to work. I managed to overlay PKCanvasViews by copying the code from the session, but I can't draw anything because the touch events are interpreted by the PDFView as scroll gestures. Any help would be appreciated :) Thank you!
4
1
2.5k
Apr ’23
PDFKit Regression ?
What is wrong with this code, on Ventura… it was OK since PDFKit exists, producing a PDF with one page, with a square... but now, a blank page ? import PDFKit let rect = NSRect(x: 0, y: 0, width: 100, height: 100) let newImage = NSImage(size: rect.size, flipped: false) { (_: NSRect) -> Bool in let path = NSBezierPath(rect: NSRect(x: 10, y: 10, width: 80, height: 80)) path.stroke() return true } let outPDF = PDFDocument() guard let pdfPage = PDFPage(image: newImage) else { fatalError("pdfPage") } outPDF.insert(pdfPage, at: 0) let outURL = URL(fileURLWithPath: "out.pdf") outPDF.write(to: outURL) Any help is welcome.
0
0
1.3k
Jan ’23
PDKKit Sample code
Trying to locate the sample code from the WWDC video on the updated PDKKit for iOS 16+ with overlay functionality. Looks like the only references are pointing to an older 2017 project. Is this sample code available anywhere? Here is the link to the announcement video: https://developer.apple.com/videos/play/wwdc2022/10089/
2
1
1.3k
Dec ’22
Accessibility of PDF on Apple platforms in 2022 and beyond
I'm finding it extremely difficult to find accurate and up-to-date information about support for accessibility with PDF on Apple's platforms, in particular Safari and Preview on iOS and Mac. For a long time it seemed that nothing worked (e.g. browsing a PDF with VoiceOver in Preview), but I've started to get some acceptable, but patchy results. Apparently things have changed under the hood since the extensive outcry at High Sierra's implementation of PDFKit but what exactly has changed? Is there a change log anywhere? Did any of the notorious PDFKit bugs from 2017 get fixed? I will mention some important jargon used in the accessibility community: "Accessibility supported". This term has a formal definition in the WCAG spec. Basically it's not enough that a file format (such as PDF) or an app (such as Safari) is hypothetically accessible, if I can't actually browse my PDF in Safari using Voiceover. Legally speaking, this information should be absolutely clear in the VPAT for Mac OS. It isn't. Lawyers with an interest in accessibility suits should take note. My questions: I've studied the latest documentation for PDFKit and can find no mention of semantic tagging, read order or the PDF/UA format in general. How does this work? Did Apple invent new names for these features, or is it simply unsupported? Can I use VoiceOver to browse a well-formed tagged PDF/UA file 'semantically' in Safari? (E.g. 'next heading' keyboard shortcut, or using the rotor). If I save a PDF from Safari or Preview, do I get a well-formed 'accessible PDF' (i.e. a "tagged PDF" file with the PDF/UA flag)? How might HTML semantics be mapped onto PDF/UA output, when saving a web page as PDF from Safari, given that there is not 100% parity between the two semantic systems? Can I browse PDF/UA files in Acrobat Reader with VoiceOver? If not, why aren't Apple and Adobe taking steps to fix this situation? I understand that Pages, Numbers and Keynote all produce tagged PDF. I assume this means some conformance with the PDF/UA 1.7 spec? Are there any omissions in support for the PDF/UA standard by this route? What are those omissions? Regarding the accessibility of the output, is there any difference between "Save as PDF", "Export PDF" and "Print to PDF" in Apple's software? Please advise on any of these points.
0
1
1.5k
Sep ’22
Highlighter Annotation Large Frame
I am using PDFKit to draw annotation over PDF view. While performing multiple highlighter annotation most of the time long pressing on the highlighter annotation is getting proper frame but in one PDF when long pressing on the highlighter annotation is getting large frame and it is selecting all the nearest highlighter. This method is giving the wrong location and this is the default method of PDFKit. let tapPageLocation = pdfView.convert(location, to: page)
0
0
1.5k
Aug ’22
Enable Live Text on PDFKit
Hi! I watched WWDC2022's 10089 session "What's New in PDFKit?" where it's said that Live Text is now compatible with PDFKit. However, I can't seem to find anything related to it in documentation or code. ImageAnalyzer needs an UIImage to work. But that would mean retrieve the current PDFPage and then convert it to UIImage which is a performance hog. How can I enable Live Text in PDFKit? thanks.
1
0
1.7k
Aug ’22
How to use PDFPageOverlayViewProvider?
I'm trying to use PDFPageOverlayViewProvider by copying the code provided in the "What's new in PDFKit" WWDC22 session here: https://developer.apple.com/videos/play/wwdc2022/10089/ I've copied the method implementations and set my pdfView's pageOverlayViewProvider property to the view where I implemented the protocol. However, when I try to run my app, the pdfView(_ view: PDFView, overlayViewFor page: PDFPage) method is never getting called. Has anyone been able to get this working successfully?
Replies
5
Boosts
1
Views
3.9k
Activity
Jul ’23
Codes are not working at this video.
https://developer.apple.com/videos/play/wwdc2022/10089/ I am trying to run codes about PDFPageOverlayViewProvider, but the codes are not working. I cannot see what I wrote or annotate. Anyone know how can I solve and make this code working?  func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? {         var resultView: PKCanvasView? = nil         if let overlayView = pageToViewMapping[page] {             resultView = (overlayView as! PKCanvasView)         } else {             let canvasView = PKCanvasView(frame: .zero)             canvasView.drawingPolicy = .anyInput             canvasView.tool = PKInkingTool(.pen, color: .yellow, width: 20)             canvasView.backgroundColor = .clear             pageToViewMapping[page] = canvasView             resultView = canvasView         }         let page = page as! WatermarkPage         if let drawing = page.drawing {             resultView?.drawing = drawing         }         return resultView     }          func pdfView(_ pdfView: PDFView, willEndDisplayingOverlayView overlayView: UIView, for page: PDFPage) {         let overlayView = overlayView as! PKCanvasView         let page = page as! WatermarkPage         page.drawing = overlayView.drawing         pageToViewMapping.removeValue(forKey: page)     }
Replies
2
Boosts
0
Views
1.2k
Activity
Jul ’23
PDFKit PencilKit annotations sample code
Hello, I was wondering if the sample code shown in Session 10089 of WWDC22 could be made available? To be more specific, I am interested in overlaying a PencilKit PKCanvasView over a PDFKit PDFView. I can't seem to get the PKCanvasView to recognize touch events. This isn't really covered in the session, and I can't get it to work. I managed to overlay PKCanvasViews by copying the code from the session, but I can't draw anything because the touch events are interpreted by the PDFView as scroll gestures. Any help would be appreciated :) Thank you!
Replies
4
Boosts
1
Views
2.5k
Activity
Apr ’23
How to add touch gesture in PDFAnnotation
Anyone Work on PDFKit, I draw a custom Annotation in PDFView, But I want to add action in Custom Annotation and I can't able to add Gesture in PDFAnnotation because it does not inherit from UIView, so is there any way to add Gesture in PDFAnnotation.
Replies
1
Boosts
0
Views
2.1k
Activity
Apr ’23
Unable to add custom menu in PDFKit using "UIEditMenuInteraction"
I'm using PDFKit to render a PDF and I have added custom menus using "UIMenuController". But it is now deprecated from iOS 16 onwards. Any help would be really appreciated. Thanks in Advance.
Replies
1
Boosts
1
Views
1.5k
Activity
Jan ’23
PDFKit Regression ?
What is wrong with this code, on Ventura… it was OK since PDFKit exists, producing a PDF with one page, with a square... but now, a blank page ? import PDFKit let rect = NSRect(x: 0, y: 0, width: 100, height: 100) let newImage = NSImage(size: rect.size, flipped: false) { (_: NSRect) -> Bool in let path = NSBezierPath(rect: NSRect(x: 10, y: 10, width: 80, height: 80)) path.stroke() return true } let outPDF = PDFDocument() guard let pdfPage = PDFPage(image: newImage) else { fatalError("pdfPage") } outPDF.insert(pdfPage, at: 0) let outURL = URL(fileURLWithPath: "out.pdf") outPDF.write(to: outURL) Any help is welcome.
Replies
0
Boosts
0
Views
1.3k
Activity
Jan ’23
PDKKit Sample code
Trying to locate the sample code from the WWDC video on the updated PDKKit for iOS 16+ with overlay functionality. Looks like the only references are pointing to an older 2017 project. Is this sample code available anywhere? Here is the link to the announcement video: https://developer.apple.com/videos/play/wwdc2022/10089/
Replies
2
Boosts
1
Views
1.3k
Activity
Dec ’22
Accessibility of PDF on Apple platforms in 2022 and beyond
I'm finding it extremely difficult to find accurate and up-to-date information about support for accessibility with PDF on Apple's platforms, in particular Safari and Preview on iOS and Mac. For a long time it seemed that nothing worked (e.g. browsing a PDF with VoiceOver in Preview), but I've started to get some acceptable, but patchy results. Apparently things have changed under the hood since the extensive outcry at High Sierra's implementation of PDFKit but what exactly has changed? Is there a change log anywhere? Did any of the notorious PDFKit bugs from 2017 get fixed? I will mention some important jargon used in the accessibility community: "Accessibility supported". This term has a formal definition in the WCAG spec. Basically it's not enough that a file format (such as PDF) or an app (such as Safari) is hypothetically accessible, if I can't actually browse my PDF in Safari using Voiceover. Legally speaking, this information should be absolutely clear in the VPAT for Mac OS. It isn't. Lawyers with an interest in accessibility suits should take note. My questions: I've studied the latest documentation for PDFKit and can find no mention of semantic tagging, read order or the PDF/UA format in general. How does this work? Did Apple invent new names for these features, or is it simply unsupported? Can I use VoiceOver to browse a well-formed tagged PDF/UA file 'semantically' in Safari? (E.g. 'next heading' keyboard shortcut, or using the rotor). If I save a PDF from Safari or Preview, do I get a well-formed 'accessible PDF' (i.e. a "tagged PDF" file with the PDF/UA flag)? How might HTML semantics be mapped onto PDF/UA output, when saving a web page as PDF from Safari, given that there is not 100% parity between the two semantic systems? Can I browse PDF/UA files in Acrobat Reader with VoiceOver? If not, why aren't Apple and Adobe taking steps to fix this situation? I understand that Pages, Numbers and Keynote all produce tagged PDF. I assume this means some conformance with the PDF/UA 1.7 spec? Are there any omissions in support for the PDF/UA standard by this route? What are those omissions? Regarding the accessibility of the output, is there any difference between "Save as PDF", "Export PDF" and "Print to PDF" in Apple's software? Please advise on any of these points.
Replies
0
Boosts
1
Views
1.5k
Activity
Sep ’22
Highlighter Annotation Large Frame
I am using PDFKit to draw annotation over PDF view. While performing multiple highlighter annotation most of the time long pressing on the highlighter annotation is getting proper frame but in one PDF when long pressing on the highlighter annotation is getting large frame and it is selecting all the nearest highlighter. This method is giving the wrong location and this is the default method of PDFKit. let tapPageLocation = pdfView.convert(location, to: page)
Replies
0
Boosts
0
Views
1.5k
Activity
Aug ’22
Enable Live Text on PDFKit
Hi! I watched WWDC2022's 10089 session "What's New in PDFKit?" where it's said that Live Text is now compatible with PDFKit. However, I can't seem to find anything related to it in documentation or code. ImageAnalyzer needs an UIImage to work. But that would mean retrieve the current PDFPage and then convert it to UIImage which is a performance hog. How can I enable Live Text in PDFKit? thanks.
Replies
1
Boosts
0
Views
1.7k
Activity
Aug ’22
Errors in sample code
There are some errors when attempting to run the sample code: Cannot convert value of type 'String' to expected argument type 'PDFAnnotationSubtype' I understand the error but I'm unsure what it's looking for. I'm running Xcode 14, targeting iOS 12 Thx for any feedback!
Replies
4
Boosts
0
Views
1.1k
Activity
Jun ’22