Hi, I’m currently working with PDFKit and using PDFView to display documents.
I’m adding free-drawing content as annotations, but I’ve noticed that these annotations are always rendered on top of the text, which ends up covering the text and making it hard to read.
What I would like to do is render these drawing annotations behind the text layer, so that the document text remains visible above the drawing.
Has anyone found a way to achieve this, or is there a recommended approach for controlling the annotation rendering order in PDFKit?
Thanks in advance!
Hello and thanks for asking.
There is no mechanism for explicitly controlling the ordering of annotation drawing. I recommend filing an enhancement request asking for some API support asking for that.
You can file an enhancement request using the Feedback Assistant. If you file a request, please post the Feedback number here.
If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?
Have you tried using overlay views for the free-drawing content that you want to display? It sounds like you may already be using them, but just in case I thought I'd mention that here. For more information about using overlay views, please see What's new in PDFKit.
note: I probably should mention that you may be able to achieve some control over the order that annotations are drawn by controlling the order that they are added to a PDFDocument; however, this is not a documented functionality and it is subject to change without notice.