PDFKit Page Rerender

I'm experiencing an issue with PDFKit where page.removeAnnotation(annotation) successfully removes the annotation from the page's data structure, but the PDFView no longer updates automatically to reflect the change visually. Issue Details:

The annotation is removed (verified by checking page.annotations.count) The PDFView display doesn't refresh to show the removal This code was working correctly before and suddenly stopped working No code changes were made on my end

Answered by DTS Engineer in 862824022

Thanks for mentioning this problem. I have seen other reports of this as well.

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. Please file a bug report, include a small Xcode project and some directions that can be used to reproduce the problem, and post the Feedback number here once you do. If you post the Feedback number here I'll check the status next time I do a sweep of forums posts where I've suggested bug reports.

Bug Reporting: How and Why? has tips on creating your bug report.

Thanks for mentioning this problem. I have seen other reports of this as well.

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. Please file a bug report, include a small Xcode project and some directions that can be used to reproduce the problem, and post the Feedback number here once you do. If you post the Feedback number here I'll check the status next time I do a sweep of forums posts where I've suggested bug reports.

Bug Reporting: How and Why? has tips on creating your bug report.

The issue occurs because PDFView doesn’t automatically refresh its rendering when annotations are removed or added dynamically. It treats annotation changes as part of the page content, so the UI may not update correctly for images or custom annotations. I solved it by forcing PDFView to reload the affected page:

func pdfEditor(_ pdfEditor: PDFEditor, didUpdateAnnotationsOn page: PDFPage) { guard let pdfView = self as? PDFView, let document = pdfView.document else { return }

let pageIndex = document.index(for: page)

// Remove and re-insert the page to trigger a full redraw
document.removePage(at: pageIndex)
document.insert(page, at: pageIndex)

pdfView.setNeedsDisplay(pdfView.bounds)

}

This forces the PDFView to completely redraw the page, ensuring added or removed annotations appear correctly. It updates only the affected page, keeping it memory-efficient and smooth.

PDFKit Page Rerender
 
 
Q