Understanding which fields allow input using PDFKit similar to QLPreviewController

26 Views Asked by At

I am currently using PDFKit to render a PDF Document.

Previously, I was using the QLPreviewController to display the pdf file and noticed that it presented a nice blue background to fields that the user could input data into when tapping the form input button:

QLPreviewController form input

If I open the same PDF form in Adobe Acrobat Reader, it does an even better job of this as it highlights the text fields but also things like drop downs and checkboxes which QLPreviewController doesn't do.

Adobe Acrobat Reader form input

My question is, how can I do something similar using PDF Kit ?

What I've tried

  1. I loop through all the annotations in a PDF file

  2. I then try to check if the field is editable

if !annotation.isReadOnly || annotation.isActivatableTextField {
    annotation.backgroundColor = .blue
}

This does add a background to some fields but:

  1. It doesn't cover the same fields as the QLPreviewController as some input fields aren't highlighted when using the looping through annotation method
  2. It doesn't cover the checkboxes and other inputs covered by Adobe Acrobat Reader

Is there a way to get similar results to Adobe Acrobat or atleast QLPreviewController

0

There are 0 best solutions below