PencilKit

RSS for tag

Capture touch input as an opaque drawing and turn it into high-quality images that can be displayed on iOS and macOS using PencilKit.

Posts under PencilKit tag

16 Posts

Post

Replies

Boosts

Views

Activity

Is there a public API or entitlement for a user-controlled Apple Pencil annotation overlay across iPadOS apps?
Hello, I am exploring an iPadOS product idea for Apple Pencil users and would like to understand the current public API boundary. The user need is a temporary, user-controlled Apple Pencil annotation layer while the user is working in another app or workspace. For example, a student may be reading in Books, Safari, a PDF app, or another educational app and want to write quick Pencil notes directly over the visible material without taking a screenshot or exporting the content first. I understand that PencilKit works inside an app's own UI, and I also understand that iPadOS sandboxing prevents third-party apps from inspecting or modifying other apps. I am not trying to bypass that model. What I am trying to determine is: Is there any current public API, extension point, or entitlement that allows a user-initiated Apple Pencil overlay session across the current iPadOS workspace? If not, is Feedback Assistant the right place to request a new PencilKit / iPadOS entitlement for this use case? Are there existing Apple-recommended patterns for this workflow beyond Quick Note, Screenshot Markup, Split View, Stage Manager, or importing content into the developer's own app? The privacy model I have in mind would be strict: The overlay is user initiated only. A visible system indicator is shown while active. The developer app receives Pencil stroke data only by default. The app cannot inspect the underlying app's view hierarchy, documents, text, or private data. Screen pixels are not captured unless the user grants separate explicit permission. The user can close or clear the overlay at any time. The closest mental model is a system-mediated Pencil annotation layer, not a background screen recorder or a way to control another app. If this is not possible today with public APIs, I would appreciate confirmation so I can file a clear enhancement request through Feedback Assistant. I also filed this as Feedback Assistant report FB23067750. Thank you.
0
0
32
5d
Shape detection for other apps?
When selecting a stroke path for object on PKCanvas, the option "Snap to Shape" appears. I understand this function is still in beta and has not made available natively to other PencilKit app. Is there a way using Stroke API to call this function directly after the user hold pencil for half a second when stroke is done drawing, just like how it behaves in native apps?
4
0
2.6k
Jan ’26
PaperKit: Adding Images is not functional
When utilizing Paperkit in its simplest form, PaperMarkupViewController does not show the option to add images. Furthermore, trying to add images directly to the PaperMarkup's insertNewImage() function does not display anything. It seems like image functionality is entirely broken on Xcode 26. This can be seen through the following example done by a fellow member here on the forums: https://gist.github.com/clarkezone/68eb3ee13b5607782ceb2e20cece4ab3
3
0
319
Nov ’25
PencilKit crash on iPad device running iOS 26.1
We are seeing this crash across several different iPad models, all of them running iPadOS 26.1. The crash did not occur before, and it started appearing consistently over the past month. This suggests that the issue may be related to changes introduced in recent iPadOS 26.1 builds. Crash Log: 0 CoreFoundation 0xc5994 (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 1 libobjc.A.dylib 0x31814 objc_exception_throw 2 Foundation 0x9465a4 (缺少 UUID 218da4dc727a3341b59e8fdb39a2d7c4) 3 Foundation 0x9469c8 (缺少 UUID 218da4dc727a3341b59e8fdb39a2d7c4) 4 Foundation 0x9468e0 (缺少 UUID 218da4dc727a3341b59e8fdb39a2d7c4) 5 PencilKit 0x100894 -[PKTextEffectsWindowObserver dealloc] 6 UIKitCore 0x22b28 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 7 UIKitCore 0x19918b8 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 8 PencilKit 0xe8448 -[PKTextInputInteraction willMoveToView:] 9 UIKitCore 0x22b1c (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 10 UIKitCore 0x19918b8 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 11 UIKitCore 0x171e094 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 12 UIKitCore 0xc896a8 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 13 UIKitCore 0xc89d70 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 14 UIKitCore 0xc89c10 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 15 CoreFoundation 0x14f78 (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 16 CoreFoundation 0x17fc2c (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 17 UIKitCore 0xc89a44 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 18 UIKitCore 0xc8a53c (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 19 UIKitCore 0xc8a638 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 20 UIKitCore 0xb9701c (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 21 UIKitCore 0xb96cd0 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 22 UIKitCore 0xba0720 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 23 UIKitCore 0xb9a608 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 24 UIKitCore 0xca4fec (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 25 UIKitCore 0x90878 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 26 UIKitCore 0x907b0 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 27 libdispatch.dylib 0x1adc _dispatch_call_block_and_release 28 libdispatch.dylib 0x1b7ec _dispatch_client_callout 29 libdispatch.dylib 0x38b24 _dispatch_main_queue_drain.cold.5 30 libdispatch.dylib 0x10ec8 _dispatch_main_queue_drain 31 libdispatch.dylib 0x10e04 _dispatch_main_queue_callback_4CF 32 CoreFoundation 0x6a2c8 (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 33 CoreFoundation 0x1db3c (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 34 CoreFoundation 0x1ca6c (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 35 GraphicsServices 0x1498 GSEventRunModal 36 UIKitCore 0x9dba4 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 37 UIKitCore 0x46a78 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 38 ---------- 0xcd20 main + 35 (main.m:35) 39 ??? 0x18a026e28 (缺少) crash_stacktrace.txt
0
1
291
Nov ’25
Drawing a PaperMarkup synchronously
The PaperMarkup class in PaperKit allows for an asynchronous function called .draw(in:, frame:) that we should call as: await paperMarkup.draw(in: context.cgContext, frame: rect) In PencilKit the PKDrawing that we can get from a PKCanvasView allows for .image(from: ,scale:) to be called synchronously. This allows me to easily render into a PKDrawing as a UIImage or a SwiftUI Image to, for example, render a thumbnail on screen. When trying to incorporate PaperKit in my project I noticed that I often need the drawing to be rendered synchronously (like I would with PKDrawing) but I can't find the way to accomplish this within PaperKit's current functionality. Is there any way to call .draw(...) in PaperKit synchronously? Feedback: FB20993683
2
0
283
Nov ’25
PaperKit: Correct approach for multi-page or infinite-canvas documents?
I’m trying to figure out how to extend PaperKit beyond a single fixed-size canvas. From what I understand, calling PaperMarkup(bounds:) creates one finite drawing region, and so far I have not figured out a reliable way to create multi-page or infinite canvases. Are any of these correct? Creating multiple PaperMarkup instances, each managed by its own PaperMarkupViewController, and arranging them in a ScrollView or similar paged container to represent multiple pages? Overlaying multiple PaperMarkup instances on top of PDFKit pages for paged annotation workflows? Or possibly another approach that works better with PaperKit’s design? I mean it has to be possible, right? Apple's native Preview app almost certainly uses it, and there are so many other notes apps that get this behavior working correctly, even if it requires using a legacy thing other than PaperKit. Curious if others have been able to find the right pattern for going beyond a single canvas.
0
0
169
Nov ’25
Apple Pencil Pro Haptic Initiation
Hello, The Apple Pencil Pro brought with it the UICanvasFeedbackGenerator API, which lets us trigger haptic feedback on discrete events initiated by the pencil. That works fine. My question then: is it possible / are we "allowed" to trigger haptic feedback on events that weren't initiated by the pencil? For example, say the user is using a left hand finger to drag a slider, while holding the pencil in their right hand-- would it be possible to make the pencil vibrate to indicate the dragged slider knob reached a certain point? Or is the rule that vibration is only possible/allowed when the pencil itself generated a touch? Thanks!
3
0
321
Sep ’25
PaperKit and PKDrawing in iPadOS 26 beta
I’ve been testing out PaperKit from beta 1 up until 3, then took a break and on my return at beta 7 I find that the .drawing property of the PaperMarkup data model has been removed, i.e. a PKDrawing can no longer be added / modified on PaperKit. Also, the shape recognition feature seems to have been removed. I see this as a tremendous drawback. I filed feedback already: FB19893338 Please bring it back.
1
0
309
Aug ’25
The PKCanvasView Created by PDFPageOverlayViewProvider cannot work normally
By setting the PKCanvasView background color to blue, I can tell that the PKCanvasView for each PDFPage is created normally, but it does not respond to touch. Specifically, whether it is finger or applepencil, all the responses of the page occur from PDFView(such as zoom and scroll), and PKCanvasView can not draw, please how to solve? class PDFAnnotatableViewController: UIViewController, PDFViewDelegate { private let pdfView = PDFView() private var pdfDocument: PDFDocument? let file: FileItem private var userSettings: UserSettings @Binding var selectedPage: Int @Binding var currentMode: Mode @Binding var latestPdfChatResponse: LatestPDFChatResponse @State private var pdfPageCoordinator = PDFPageCoordinator() @ObservedObject var userMessage: ChatMessage init(file: FileItem, userSettings: UserSettings, drawDataList: Binding<[DrawDataItem]>, selectedPage: Binding<Int>, currentMode: Binding<Mode>, latestPdfChatResponse: Binding<LatestPDFChatResponse>, userMessage: ChatMessage) { self.file = file self.userSettings = userSettings self._selectedPage = selectedPage self._currentMode = currentMode self._latestPdfChatResponse = latestPdfChatResponse self.userMessage = userMessage super.init(nibName: nil, bundle: nil) DispatchQueue.global(qos: .userInitiated).async { if let document = PDFDocument(url: file.pdfLocalUrl) { DispatchQueue.main.async { self.pdfDocument = document self.pdfView.document = document self.goToPage(selectedPage: selectedPage.wrappedValue - 1) } } } } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() setupPDFView() } private func setupPDFView() { pdfView.delegate = self pdfView.autoScales = true pdfView.displayMode = .singlePage pdfView.displayDirection = .vertical pdfView.backgroundColor = .white pdfView.usePageViewController(true) pdfView.displaysPageBreaks = false pdfView.displaysAsBook = false pdfView.minScaleFactor = 0.8 pdfView.maxScaleFactor = 3.5 pdfView.pageOverlayViewProvider = pdfPageCoordinator if let document = pdfDocument { pdfView.document = document goToPage(selectedPage: selectedPage) } pdfView.frame = view.bounds pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(pdfView) NotificationCenter.default.addObserver( self, selector: #selector(handlePageChange), name: .PDFViewPageChanged, object: pdfView ) } // Dealing with page turning @objc private func handlePageChange(notification: Notification) { guard let currentPage = pdfView.currentPage, let document = pdfView.document else { return } let currentPageIndex = document.index(for: currentPage) if currentPageIndex != selectedPage - 1 { DispatchQueue.main.async { self.selectedPage = currentPageIndex + 1 } } } func goToPage(selectedPage: Int) { guard let document = pdfView.document else { return } if let page = document.page(at: selectedPage) { pdfView.go(to: page) } } // Switch function func togglecurrentMode(currentMode: Mode){ DispatchQueue.main.async { if self.currentMode == .none{ self.pdfView.usePageViewController(true) self.pdfView.isUserInteractionEnabled = true } else if self.currentMode == .annotation { if let page = self.pdfView.currentPage { if let canvasView = self.pdfPageCoordinator.getCanvasView(forPage: page) { canvasView.isUserInteractionEnabled = true canvasView.tool = PKInkingTool(.pen, color: .red, width: 20) canvasView.drawingPolicy = .anyInput canvasView.setNeedsDisplay() } } } } } } class MyPDFPage: PDFPage { var drawing: PKDrawing? func setDrawing(_ drawing: PKDrawing) { self.drawing = drawing } func getDrawing() -> PKDrawing? { return self.drawing } } class PDFPageCoordinator: NSObject, PDFPageOverlayViewProvider { var pageToViewMapping = [PDFPage: PKCanvasView]() func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? { var resultView: PKCanvasView? = nil if let overlayView = pageToViewMapping[page] { resultView = overlayView } else { let canvasView = PKCanvasView(frame: view.bounds) canvasView.drawingPolicy = .anyInput canvasView.tool = PKInkingTool(.pen, color: .systemYellow, width: 20) canvasView.backgroundColor = .blue pageToViewMapping[page] = canvasView resultView = canvasView } if let page = page as? MyPDFPage, let drawing = page.drawing { resultView?.drawing = drawing } return resultView } func pdfView(_ pdfView: PDFView, willEndDisplayingOverlayView overlayView: UIView, for page: PDFPage) { guard let overlayView = overlayView as? PKCanvasView, let page = page as? MyPDFPage else { return } page.drawing = overlayView.drawing pageToViewMapping.removeValue(forKey: page) } func savePDFDocument(_ pdfDocument: PDFDocument) -> Data { for i in 0..<pdfDocument.pageCount { if let page = pdfDocument.page(at: i) as? MyPDFPage, let drawing = page.drawing { let newAnnotation = PDFAnnotation(bounds: drawing.bounds, forType: .stamp, withProperties: nil) let codedData = try! NSKeyedArchiver.archivedData(withRootObject: drawing, requiringSecureCoding: true) newAnnotation.setValue(codedData, forAnnotationKey: PDFAnnotationKey(rawValue: "drawingData")) page.addAnnotation(newAnnotation) } } let options = [PDFDocumentWriteOption.burnInAnnotationsOption: true] if let resultData = pdfDocument.dataRepresentation(options: options) { return resultData } return Data() } func getCanvasView(forPage page: PDFPage) -> PKCanvasView? { return pageToViewMapping[page] } } Is there an error in my code? Please tell me how to make PKCanvasView painting normally?
1
0
504
Aug ’25
Apple Pencil Pro not staying connected in iPadOS26 beta
I have a new M4 iPad Air and a brand new Apple Pencil Pro. It was working well until I installed iPadOS 26.0 (23A5297m) beta. Now, when using GoodNotes to write the Pencil functions for about 6-8 seconds and then disconnects for 2-3 seconds and then reconnects. You can imagine how disruptive this is. It does the same thing trying to highlight in the Kindle app, so I think it is an iOS issue. As I write this, I am discovering that the Pencil is not wanting to stay connected at all despite showing up in the list of Bluetooth devices and connecting temporarily. I've tried forgetting and reconnecting the Pencil several times. It is charged to 100%, and I receive the alert that the iPad detects the Pencil. Is anyone else having this issue? Do I need to assume this is being addressed?
2
0
489
Jul ’25
Feature Request: Dual Apple Pencil Pro Use or Charging Dock Support
Hi everyone 👋 I’ve been using the Apple Pencil Pro with my iPad Pro M4 and absolutely love it — the squeeze gesture, rotation, and haptics are amazing for creative work. But I’ve run into a little roadblock… Right now, only one Pencil Pro can be paired at a time. So while one is charging, you can’t use another as a backup without unpairing and re-pairing, which interrupts the workflow. I’d really love to see one of two things: The ability to use one Pencil while another charges or An official external charger (or support for third-party ones) Personally, I’d happily buy both a second Pencil and a charger if this became possible. I’ve even chatted with other creatives who feel the same — it would make a huge difference for long projects or working on the go. Just wanted to share this idea and see if anyone else here would like this too. Thanks for reading!
1
0
489
Jul ’25
Does the canvas view on top of the PDFView not re-render?
I added a canvas view using PDFPageOverlayViewProvider. When I zoom the PDFView, the drawing is scaled, but its quality becomes blurry. How can I fix this? import SwiftUI import PDFKit import PencilKit import CoreGraphics struct ContentView: View { var body: some View { if let url = Bundle.main.url(forResource: "sample", withExtension: "pdf"), let data = try? Data(contentsOf: url), let document = PDFDocument(data: data) { PDFRepresentableView(document: document) } else { Text("fail") } } } #Preview { ContentView() } struct PDFRepresentableView: UIViewRepresentable { let document: PDFDocument let pdfView = PDFView() func makeUIView(context: Context) -> PDFView { pdfView.displayMode = .singlePageContinuous pdfView.usePageViewController(false) pdfView.displayDirection = .vertical pdfView.pageOverlayViewProvider = context.coordinator pdfView.document = document pdfView.autoScales = false pdfView.minScaleFactor = 0.7 pdfView.maxScaleFactor = 4 return pdfView } func updateUIView(_ uiView: PDFView, context: Context) { // Optional: update logic if needed } func makeCoordinator() -> CustomCoordinator { return CustomCoordinator(parent: self) } } class CustomCoordinator: NSObject, PDFPageOverlayViewProvider, PKCanvasViewDelegate { let parent: PDFRepresentableView init(parent: PDFRepresentableView) { self.parent = parent } func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? { let result = UIView() let canvasView = PKCanvasView() canvasView.drawingPolicy = .anyInput canvasView.tool = PKInkingTool(.pen, color: .blue, width: 20) canvasView.translatesAutoresizingMaskIntoConstraints = false result.addSubview(canvasView) NSLayoutConstraint.activate([ canvasView.leadingAnchor.constraint(equalTo: result.leadingAnchor), canvasView.trailingAnchor.constraint(equalTo: result.trailingAnchor), canvasView.topAnchor.constraint(equalTo: result.topAnchor), canvasView.bottomAnchor.constraint(equalTo: result.bottomAnchor) ]) for subView in view.documentView?.subviews ?? [] { subView.isUserInteractionEnabled = true } result.layoutIfNeeded() return result } }
1
0
383
Jul ’25
CanvasView overlay on PDFKit loses quality when zoomed – how to preserve drawing resolution?
Hi all, I’m currently building a SwiftUI app that overlays a PKCanvasView onto each page of a PDFView using PDFPageOverlayViewProvider. It works well at the initial scale, but once I zoom into the PDF, the drawings on the PKCanvasView appear blurry or pixelated, even though the PDF itself remains crisp. I’m trying to adjust canvasView.contentScaleFactor relative to pdfView.scaleFactor to preserve the drawing quality. Here’s a simplified version of the relevant code: import SwiftUI import PDFKit import PencilKit struct ContentView: View { var body: some View { if let url = Bundle.main.url(forResource: "sample", withExtension: "pdf"), let data = try? Data(contentsOf: url), let document = PDFDocument(data: data) { PDFRepresentableView(document: document) } else { Text("") } } } #Preview { ContentView() } struct PDFRepresentableView: UIViewRepresentable { let document: PDFDocument let pdfView = PDFView() func makeUIView(context: Context) -> PDFView { pdfView.displayMode = .singlePageContinuous pdfView.usePageViewController(false) pdfView.displayDirection = .vertical pdfView.pageOverlayViewProvider = context.coordinator pdfView.document = document pdfView.autoScales = false pdfView.minScaleFactor = 0.7 pdfView.maxScaleFactor = 4 NotificationCenter.default.addObserver( context.coordinator, selector: #selector(context.coordinator.onPageZoomAndPan), name: .PDFViewScaleChanged, object: pdfView ) return pdfView } func updateUIView(_ uiView: PDFView, context: Context) { // Optional: update logic if needed } func makeCoordinator() -> CustomCoordinator { return CustomCoordinator(parent: self) } } class CustomCoordinator: NSObject, PDFPageOverlayViewProvider, PKCanvasViewDelegate { let parent: PDFRepresentableView init(parent: PDFRepresentableView) { self.parent = parent } func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? { let canvasView = PKCanvasView() let rect = page.bounds(for: .mediaBox) canvasView.drawingPolicy = .anyInput canvasView.tool = PKInkingTool(.pen, color: .black, width: 10) canvasView.translatesAutoresizingMaskIntoConstraints = true canvasView.backgroundColor = .red.withAlphaComponent(0.1) canvasView.frame = rect canvasView.isScrollEnabled = false for subView in view.documentView?.subviews ?? [] { subView.isUserInteractionEnabled = true } return canvasView } @objc func onPageZoomAndPan() { parent.pdfView.documentView?.subviews.forEach { subview in if subview.theClassName == "PDFPageView", let pageViewPrivate = subview.value(forKey: "_private") as? NSObject, let page = pageViewPrivate.value(forKey: "page") as? PDFPage { subview.subviews.forEach { subview in if let canvasView = subview as? PKCanvasView { let zoomScale = parent.pdfView.scaleFactor canvasView.contentScaleFactor = UIScreen.main.scale * zoomScale canvasView.drawing = canvasView.drawing canvasView.setNeedsDisplay() canvasView.layoutIfNeeded() } } } } print("Zoom changed. Current scale: \(parent.pdfView.scaleFactor)") } } extension NSObject { var theClassName: String { return NSStringFromClass(type(of: self)) } } But this doesn’t seem to improve the rendered quality. The lines still appear blurry when zoomed in. What I’ve tried: • Adjusting contentScaleFactor and forcing redraw • Reassigning canvasView.drawing • Calling setNeedsDisplay() and layoutIfNeeded() None of these approaches seem to re-render the canvas at a higher resolution or match the zoomed scale of the PDF. My questions: 1. Is there a correct way to scale PKCanvasView content to match PDF zoom levels? 2. Should I recreate the canvas or drawing when zoom changes? 3. Is PKCanvasView just not intended to handle high zoom fidelity? If anyone has successfully overlaid high-resolution canvas drawing on a zoomable PDFView, I’d love to hear how you managed it. Thanks in advance!
0
0
304
Jul ’25
How to sync stroke between two PKCanvasViews with one in a UIScrollView with scale not 1
I got 3 PKCanvasView, 2 below the Major one. Users draw lines on the top one, then sync the last stroke to the one underneath. If the stroke crosses two PKCanvasView, we replace the stroke with a bezier curve. If a stroke doesn't cross regions, we sync the stroke to the one below it(B) as if it is drawn directly on B. The problem is if the B is inside a UIScrollview with a zoom scale not 1, the stroke from major to B will shrink or grow. Does anybody have a solution for this please? What I did Also put the major canvas into a uiScrollview, and make sure the zoomScale is the same as the B. for scale >=1, it works as expected, for scale < 1, sometimes it works, sometimes it doesn't. for example, 0.5, 0.6, 0.8, 0.5 doesn't work, 0.6, 0.8 works, I don't know why. What it costs It cost me 16*4 hours for these days. I didn't find a solution. Hopefully, some one can solve it.
0
0
283
Jul ’25
Is there a public API or entitlement for a user-controlled Apple Pencil annotation overlay across iPadOS apps?
Hello, I am exploring an iPadOS product idea for Apple Pencil users and would like to understand the current public API boundary. The user need is a temporary, user-controlled Apple Pencil annotation layer while the user is working in another app or workspace. For example, a student may be reading in Books, Safari, a PDF app, or another educational app and want to write quick Pencil notes directly over the visible material without taking a screenshot or exporting the content first. I understand that PencilKit works inside an app's own UI, and I also understand that iPadOS sandboxing prevents third-party apps from inspecting or modifying other apps. I am not trying to bypass that model. What I am trying to determine is: Is there any current public API, extension point, or entitlement that allows a user-initiated Apple Pencil overlay session across the current iPadOS workspace? If not, is Feedback Assistant the right place to request a new PencilKit / iPadOS entitlement for this use case? Are there existing Apple-recommended patterns for this workflow beyond Quick Note, Screenshot Markup, Split View, Stage Manager, or importing content into the developer's own app? The privacy model I have in mind would be strict: The overlay is user initiated only. A visible system indicator is shown while active. The developer app receives Pencil stroke data only by default. The app cannot inspect the underlying app's view hierarchy, documents, text, or private data. Screen pixels are not captured unless the user grants separate explicit permission. The user can close or clear the overlay at any time. The closest mental model is a system-mediated Pencil annotation layer, not a background screen recorder or a way to control another app. If this is not possible today with public APIs, I would appreciate confirmation so I can file a clear enhancement request through Feedback Assistant. I also filed this as Feedback Assistant report FB23067750. Thank you.
Replies
0
Boosts
0
Views
32
Activity
5d
PencilKit Shape Recognition ont wokring?
I've integrated PencilKit into my app, but I've noticed that shape recognition isn't working during drawing, even though it works perfectly in the Notes app. Is this a bug, or is shape recognition simply not supported in PencilKit for Swift?
Replies
1
Boosts
0
Views
410
Activity
Jan ’26
Shape detection for other apps?
When selecting a stroke path for object on PKCanvas, the option "Snap to Shape" appears. I understand this function is still in beta and has not made available natively to other PencilKit app. Is there a way using Stroke API to call this function directly after the user hold pencil for half a second when stroke is done drawing, just like how it behaves in native apps?
Replies
4
Boosts
0
Views
2.6k
Activity
Jan ’26
PaperKit: Adding Images is not functional
When utilizing Paperkit in its simplest form, PaperMarkupViewController does not show the option to add images. Furthermore, trying to add images directly to the PaperMarkup's insertNewImage() function does not display anything. It seems like image functionality is entirely broken on Xcode 26. This can be seen through the following example done by a fellow member here on the forums: https://gist.github.com/clarkezone/68eb3ee13b5607782ceb2e20cece4ab3
Replies
3
Boosts
0
Views
319
Activity
Nov ’25
PencilKit crash on iPad device running iOS 26.1
We are seeing this crash across several different iPad models, all of them running iPadOS 26.1. The crash did not occur before, and it started appearing consistently over the past month. This suggests that the issue may be related to changes introduced in recent iPadOS 26.1 builds. Crash Log: 0 CoreFoundation 0xc5994 (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 1 libobjc.A.dylib 0x31814 objc_exception_throw 2 Foundation 0x9465a4 (缺少 UUID 218da4dc727a3341b59e8fdb39a2d7c4) 3 Foundation 0x9469c8 (缺少 UUID 218da4dc727a3341b59e8fdb39a2d7c4) 4 Foundation 0x9468e0 (缺少 UUID 218da4dc727a3341b59e8fdb39a2d7c4) 5 PencilKit 0x100894 -[PKTextEffectsWindowObserver dealloc] 6 UIKitCore 0x22b28 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 7 UIKitCore 0x19918b8 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 8 PencilKit 0xe8448 -[PKTextInputInteraction willMoveToView:] 9 UIKitCore 0x22b1c (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 10 UIKitCore 0x19918b8 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 11 UIKitCore 0x171e094 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 12 UIKitCore 0xc896a8 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 13 UIKitCore 0xc89d70 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 14 UIKitCore 0xc89c10 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 15 CoreFoundation 0x14f78 (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 16 CoreFoundation 0x17fc2c (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 17 UIKitCore 0xc89a44 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 18 UIKitCore 0xc8a53c (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 19 UIKitCore 0xc8a638 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 20 UIKitCore 0xb9701c (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 21 UIKitCore 0xb96cd0 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 22 UIKitCore 0xba0720 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 23 UIKitCore 0xb9a608 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 24 UIKitCore 0xca4fec (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 25 UIKitCore 0x90878 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 26 UIKitCore 0x907b0 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 27 libdispatch.dylib 0x1adc _dispatch_call_block_and_release 28 libdispatch.dylib 0x1b7ec _dispatch_client_callout 29 libdispatch.dylib 0x38b24 _dispatch_main_queue_drain.cold.5 30 libdispatch.dylib 0x10ec8 _dispatch_main_queue_drain 31 libdispatch.dylib 0x10e04 _dispatch_main_queue_callback_4CF 32 CoreFoundation 0x6a2c8 (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 33 CoreFoundation 0x1db3c (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 34 CoreFoundation 0x1ca6c (缺少 UUID b4a0233bf37d3ef6a977e4f36199c5a4) 35 GraphicsServices 0x1498 GSEventRunModal 36 UIKitCore 0x9dba4 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 37 UIKitCore 0x46a78 (缺少 UUID a0e1cefbfd0136f9b82351b092e4dbc6) 38 ---------- 0xcd20 main + 35 (main.m:35) 39 ??? 0x18a026e28 (缺少) crash_stacktrace.txt
Replies
0
Boosts
1
Views
291
Activity
Nov ’25
Drawing a PaperMarkup synchronously
The PaperMarkup class in PaperKit allows for an asynchronous function called .draw(in:, frame:) that we should call as: await paperMarkup.draw(in: context.cgContext, frame: rect) In PencilKit the PKDrawing that we can get from a PKCanvasView allows for .image(from: ,scale:) to be called synchronously. This allows me to easily render into a PKDrawing as a UIImage or a SwiftUI Image to, for example, render a thumbnail on screen. When trying to incorporate PaperKit in my project I noticed that I often need the drawing to be rendered synchronously (like I would with PKDrawing) but I can't find the way to accomplish this within PaperKit's current functionality. Is there any way to call .draw(...) in PaperKit synchronously? Feedback: FB20993683
Replies
2
Boosts
0
Views
283
Activity
Nov ’25
PaperKit: Correct approach for multi-page or infinite-canvas documents?
I’m trying to figure out how to extend PaperKit beyond a single fixed-size canvas. From what I understand, calling PaperMarkup(bounds:) creates one finite drawing region, and so far I have not figured out a reliable way to create multi-page or infinite canvases. Are any of these correct? Creating multiple PaperMarkup instances, each managed by its own PaperMarkupViewController, and arranging them in a ScrollView or similar paged container to represent multiple pages? Overlaying multiple PaperMarkup instances on top of PDFKit pages for paged annotation workflows? Or possibly another approach that works better with PaperKit’s design? I mean it has to be possible, right? Apple's native Preview app almost certainly uses it, and there are so many other notes apps that get this behavior working correctly, even if it requires using a legacy thing other than PaperKit. Curious if others have been able to find the right pattern for going beyond a single canvas.
Replies
0
Boosts
0
Views
169
Activity
Nov ’25
Apple Pencil Pro Haptic Initiation
Hello, The Apple Pencil Pro brought with it the UICanvasFeedbackGenerator API, which lets us trigger haptic feedback on discrete events initiated by the pencil. That works fine. My question then: is it possible / are we "allowed" to trigger haptic feedback on events that weren't initiated by the pencil? For example, say the user is using a left hand finger to drag a slider, while holding the pencil in their right hand-- would it be possible to make the pencil vibrate to indicate the dragged slider knob reached a certain point? Or is the rule that vibration is only possible/allowed when the pencil itself generated a touch? Thanks!
Replies
3
Boosts
0
Views
321
Activity
Sep ’25
PaperKit and PKDrawing in iPadOS 26 beta
I’ve been testing out PaperKit from beta 1 up until 3, then took a break and on my return at beta 7 I find that the .drawing property of the PaperMarkup data model has been removed, i.e. a PKDrawing can no longer be added / modified on PaperKit. Also, the shape recognition feature seems to have been removed. I see this as a tremendous drawback. I filed feedback already: FB19893338 Please bring it back.
Replies
1
Boosts
0
Views
309
Activity
Aug ’25
The PKCanvasView Created by PDFPageOverlayViewProvider cannot work normally
By setting the PKCanvasView background color to blue, I can tell that the PKCanvasView for each PDFPage is created normally, but it does not respond to touch. Specifically, whether it is finger or applepencil, all the responses of the page occur from PDFView(such as zoom and scroll), and PKCanvasView can not draw, please how to solve? class PDFAnnotatableViewController: UIViewController, PDFViewDelegate { private let pdfView = PDFView() private var pdfDocument: PDFDocument? let file: FileItem private var userSettings: UserSettings @Binding var selectedPage: Int @Binding var currentMode: Mode @Binding var latestPdfChatResponse: LatestPDFChatResponse @State private var pdfPageCoordinator = PDFPageCoordinator() @ObservedObject var userMessage: ChatMessage init(file: FileItem, userSettings: UserSettings, drawDataList: Binding<[DrawDataItem]>, selectedPage: Binding<Int>, currentMode: Binding<Mode>, latestPdfChatResponse: Binding<LatestPDFChatResponse>, userMessage: ChatMessage) { self.file = file self.userSettings = userSettings self._selectedPage = selectedPage self._currentMode = currentMode self._latestPdfChatResponse = latestPdfChatResponse self.userMessage = userMessage super.init(nibName: nil, bundle: nil) DispatchQueue.global(qos: .userInitiated).async { if let document = PDFDocument(url: file.pdfLocalUrl) { DispatchQueue.main.async { self.pdfDocument = document self.pdfView.document = document self.goToPage(selectedPage: selectedPage.wrappedValue - 1) } } } } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() setupPDFView() } private func setupPDFView() { pdfView.delegate = self pdfView.autoScales = true pdfView.displayMode = .singlePage pdfView.displayDirection = .vertical pdfView.backgroundColor = .white pdfView.usePageViewController(true) pdfView.displaysPageBreaks = false pdfView.displaysAsBook = false pdfView.minScaleFactor = 0.8 pdfView.maxScaleFactor = 3.5 pdfView.pageOverlayViewProvider = pdfPageCoordinator if let document = pdfDocument { pdfView.document = document goToPage(selectedPage: selectedPage) } pdfView.frame = view.bounds pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(pdfView) NotificationCenter.default.addObserver( self, selector: #selector(handlePageChange), name: .PDFViewPageChanged, object: pdfView ) } // Dealing with page turning @objc private func handlePageChange(notification: Notification) { guard let currentPage = pdfView.currentPage, let document = pdfView.document else { return } let currentPageIndex = document.index(for: currentPage) if currentPageIndex != selectedPage - 1 { DispatchQueue.main.async { self.selectedPage = currentPageIndex + 1 } } } func goToPage(selectedPage: Int) { guard let document = pdfView.document else { return } if let page = document.page(at: selectedPage) { pdfView.go(to: page) } } // Switch function func togglecurrentMode(currentMode: Mode){ DispatchQueue.main.async { if self.currentMode == .none{ self.pdfView.usePageViewController(true) self.pdfView.isUserInteractionEnabled = true } else if self.currentMode == .annotation { if let page = self.pdfView.currentPage { if let canvasView = self.pdfPageCoordinator.getCanvasView(forPage: page) { canvasView.isUserInteractionEnabled = true canvasView.tool = PKInkingTool(.pen, color: .red, width: 20) canvasView.drawingPolicy = .anyInput canvasView.setNeedsDisplay() } } } } } } class MyPDFPage: PDFPage { var drawing: PKDrawing? func setDrawing(_ drawing: PKDrawing) { self.drawing = drawing } func getDrawing() -> PKDrawing? { return self.drawing } } class PDFPageCoordinator: NSObject, PDFPageOverlayViewProvider { var pageToViewMapping = [PDFPage: PKCanvasView]() func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? { var resultView: PKCanvasView? = nil if let overlayView = pageToViewMapping[page] { resultView = overlayView } else { let canvasView = PKCanvasView(frame: view.bounds) canvasView.drawingPolicy = .anyInput canvasView.tool = PKInkingTool(.pen, color: .systemYellow, width: 20) canvasView.backgroundColor = .blue pageToViewMapping[page] = canvasView resultView = canvasView } if let page = page as? MyPDFPage, let drawing = page.drawing { resultView?.drawing = drawing } return resultView } func pdfView(_ pdfView: PDFView, willEndDisplayingOverlayView overlayView: UIView, for page: PDFPage) { guard let overlayView = overlayView as? PKCanvasView, let page = page as? MyPDFPage else { return } page.drawing = overlayView.drawing pageToViewMapping.removeValue(forKey: page) } func savePDFDocument(_ pdfDocument: PDFDocument) -> Data { for i in 0..<pdfDocument.pageCount { if let page = pdfDocument.page(at: i) as? MyPDFPage, let drawing = page.drawing { let newAnnotation = PDFAnnotation(bounds: drawing.bounds, forType: .stamp, withProperties: nil) let codedData = try! NSKeyedArchiver.archivedData(withRootObject: drawing, requiringSecureCoding: true) newAnnotation.setValue(codedData, forAnnotationKey: PDFAnnotationKey(rawValue: "drawingData")) page.addAnnotation(newAnnotation) } } let options = [PDFDocumentWriteOption.burnInAnnotationsOption: true] if let resultData = pdfDocument.dataRepresentation(options: options) { return resultData } return Data() } func getCanvasView(forPage page: PDFPage) -> PKCanvasView? { return pageToViewMapping[page] } } Is there an error in my code? Please tell me how to make PKCanvasView painting normally?
Replies
1
Boosts
0
Views
504
Activity
Aug ’25
Apple Pencil Pro not staying connected in iPadOS26 beta
I have a new M4 iPad Air and a brand new Apple Pencil Pro. It was working well until I installed iPadOS 26.0 (23A5297m) beta. Now, when using GoodNotes to write the Pencil functions for about 6-8 seconds and then disconnects for 2-3 seconds and then reconnects. You can imagine how disruptive this is. It does the same thing trying to highlight in the Kindle app, so I think it is an iOS issue. As I write this, I am discovering that the Pencil is not wanting to stay connected at all despite showing up in the list of Bluetooth devices and connecting temporarily. I've tried forgetting and reconnecting the Pencil several times. It is charged to 100%, and I receive the alert that the iPad detects the Pencil. Is anyone else having this issue? Do I need to assume this is being addressed?
Replies
2
Boosts
0
Views
489
Activity
Jul ’25
Feature Request: Dual Apple Pencil Pro Use or Charging Dock Support
Hi everyone 👋 I’ve been using the Apple Pencil Pro with my iPad Pro M4 and absolutely love it — the squeeze gesture, rotation, and haptics are amazing for creative work. But I’ve run into a little roadblock… Right now, only one Pencil Pro can be paired at a time. So while one is charging, you can’t use another as a backup without unpairing and re-pairing, which interrupts the workflow. I’d really love to see one of two things: The ability to use one Pencil while another charges or An official external charger (or support for third-party ones) Personally, I’d happily buy both a second Pencil and a charger if this became possible. I’ve even chatted with other creatives who feel the same — it would make a huge difference for long projects or working on the go. Just wanted to share this idea and see if anyone else here would like this too. Thanks for reading!
Replies
1
Boosts
0
Views
489
Activity
Jul ’25
Does the canvas view on top of the PDFView not re-render?
I added a canvas view using PDFPageOverlayViewProvider. When I zoom the PDFView, the drawing is scaled, but its quality becomes blurry. How can I fix this? import SwiftUI import PDFKit import PencilKit import CoreGraphics struct ContentView: View { var body: some View { if let url = Bundle.main.url(forResource: "sample", withExtension: "pdf"), let data = try? Data(contentsOf: url), let document = PDFDocument(data: data) { PDFRepresentableView(document: document) } else { Text("fail") } } } #Preview { ContentView() } struct PDFRepresentableView: UIViewRepresentable { let document: PDFDocument let pdfView = PDFView() func makeUIView(context: Context) -> PDFView { pdfView.displayMode = .singlePageContinuous pdfView.usePageViewController(false) pdfView.displayDirection = .vertical pdfView.pageOverlayViewProvider = context.coordinator pdfView.document = document pdfView.autoScales = false pdfView.minScaleFactor = 0.7 pdfView.maxScaleFactor = 4 return pdfView } func updateUIView(_ uiView: PDFView, context: Context) { // Optional: update logic if needed } func makeCoordinator() -> CustomCoordinator { return CustomCoordinator(parent: self) } } class CustomCoordinator: NSObject, PDFPageOverlayViewProvider, PKCanvasViewDelegate { let parent: PDFRepresentableView init(parent: PDFRepresentableView) { self.parent = parent } func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? { let result = UIView() let canvasView = PKCanvasView() canvasView.drawingPolicy = .anyInput canvasView.tool = PKInkingTool(.pen, color: .blue, width: 20) canvasView.translatesAutoresizingMaskIntoConstraints = false result.addSubview(canvasView) NSLayoutConstraint.activate([ canvasView.leadingAnchor.constraint(equalTo: result.leadingAnchor), canvasView.trailingAnchor.constraint(equalTo: result.trailingAnchor), canvasView.topAnchor.constraint(equalTo: result.topAnchor), canvasView.bottomAnchor.constraint(equalTo: result.bottomAnchor) ]) for subView in view.documentView?.subviews ?? [] { subView.isUserInteractionEnabled = true } result.layoutIfNeeded() return result } }
Replies
1
Boosts
0
Views
383
Activity
Jul ’25
CanvasView overlay on PDFKit loses quality when zoomed – how to preserve drawing resolution?
Hi all, I’m currently building a SwiftUI app that overlays a PKCanvasView onto each page of a PDFView using PDFPageOverlayViewProvider. It works well at the initial scale, but once I zoom into the PDF, the drawings on the PKCanvasView appear blurry or pixelated, even though the PDF itself remains crisp. I’m trying to adjust canvasView.contentScaleFactor relative to pdfView.scaleFactor to preserve the drawing quality. Here’s a simplified version of the relevant code: import SwiftUI import PDFKit import PencilKit struct ContentView: View { var body: some View { if let url = Bundle.main.url(forResource: "sample", withExtension: "pdf"), let data = try? Data(contentsOf: url), let document = PDFDocument(data: data) { PDFRepresentableView(document: document) } else { Text("") } } } #Preview { ContentView() } struct PDFRepresentableView: UIViewRepresentable { let document: PDFDocument let pdfView = PDFView() func makeUIView(context: Context) -> PDFView { pdfView.displayMode = .singlePageContinuous pdfView.usePageViewController(false) pdfView.displayDirection = .vertical pdfView.pageOverlayViewProvider = context.coordinator pdfView.document = document pdfView.autoScales = false pdfView.minScaleFactor = 0.7 pdfView.maxScaleFactor = 4 NotificationCenter.default.addObserver( context.coordinator, selector: #selector(context.coordinator.onPageZoomAndPan), name: .PDFViewScaleChanged, object: pdfView ) return pdfView } func updateUIView(_ uiView: PDFView, context: Context) { // Optional: update logic if needed } func makeCoordinator() -> CustomCoordinator { return CustomCoordinator(parent: self) } } class CustomCoordinator: NSObject, PDFPageOverlayViewProvider, PKCanvasViewDelegate { let parent: PDFRepresentableView init(parent: PDFRepresentableView) { self.parent = parent } func pdfView(_ view: PDFView, overlayViewFor page: PDFPage) -> UIView? { let canvasView = PKCanvasView() let rect = page.bounds(for: .mediaBox) canvasView.drawingPolicy = .anyInput canvasView.tool = PKInkingTool(.pen, color: .black, width: 10) canvasView.translatesAutoresizingMaskIntoConstraints = true canvasView.backgroundColor = .red.withAlphaComponent(0.1) canvasView.frame = rect canvasView.isScrollEnabled = false for subView in view.documentView?.subviews ?? [] { subView.isUserInteractionEnabled = true } return canvasView } @objc func onPageZoomAndPan() { parent.pdfView.documentView?.subviews.forEach { subview in if subview.theClassName == "PDFPageView", let pageViewPrivate = subview.value(forKey: "_private") as? NSObject, let page = pageViewPrivate.value(forKey: "page") as? PDFPage { subview.subviews.forEach { subview in if let canvasView = subview as? PKCanvasView { let zoomScale = parent.pdfView.scaleFactor canvasView.contentScaleFactor = UIScreen.main.scale * zoomScale canvasView.drawing = canvasView.drawing canvasView.setNeedsDisplay() canvasView.layoutIfNeeded() } } } } print("Zoom changed. Current scale: \(parent.pdfView.scaleFactor)") } } extension NSObject { var theClassName: String { return NSStringFromClass(type(of: self)) } } But this doesn’t seem to improve the rendered quality. The lines still appear blurry when zoomed in. What I’ve tried: • Adjusting contentScaleFactor and forcing redraw • Reassigning canvasView.drawing • Calling setNeedsDisplay() and layoutIfNeeded() None of these approaches seem to re-render the canvas at a higher resolution or match the zoomed scale of the PDF. My questions: 1. Is there a correct way to scale PKCanvasView content to match PDF zoom levels? 2. Should I recreate the canvas or drawing when zoom changes? 3. Is PKCanvasView just not intended to handle high zoom fidelity? If anyone has successfully overlaid high-resolution canvas drawing on a zoomable PDFView, I’d love to hear how you managed it. Thanks in advance!
Replies
0
Boosts
0
Views
304
Activity
Jul ’25
Is it possible to access the currently drawn (in-progress) drawing data from the canvas view?
The canvasView in PKCanvasViewDelegate only holds the drawing data up to the most recently completed stroke. I want to access the currently in-progress drawing (before the pencil is lifted) in order to measure the path’s size — but I can’t find a way to do it. Is there any way you could help me with this?
Replies
1
Boosts
0
Views
421
Activity
Jul ’25
How to sync stroke between two PKCanvasViews with one in a UIScrollView with scale not 1
I got 3 PKCanvasView, 2 below the Major one. Users draw lines on the top one, then sync the last stroke to the one underneath. If the stroke crosses two PKCanvasView, we replace the stroke with a bezier curve. If a stroke doesn't cross regions, we sync the stroke to the one below it(B) as if it is drawn directly on B. The problem is if the B is inside a UIScrollview with a zoom scale not 1, the stroke from major to B will shrink or grow. Does anybody have a solution for this please? What I did Also put the major canvas into a uiScrollview, and make sure the zoomScale is the same as the B. for scale >=1, it works as expected, for scale < 1, sometimes it works, sometimes it doesn't. for example, 0.5, 0.6, 0.8, 0.5 doesn't work, 0.6, 0.8 works, I don't know why. What it costs It cost me 16*4 hours for these days. I didn't find a solution. Hopefully, some one can solve it.
Replies
0
Boosts
0
Views
283
Activity
Jul ’25