Open mkhatib opened 1 year ago
I have the same problem, in my case, I could find the page with pages.find((x) => x.ref === widget.P())
.
I ended up doing
const page = doc.findPageForAnnotationRef(field.ref) ?? pages.find((x) => x.ref === widget.P());
What were you trying to do?
I am trying to find the page on which a PDF form radio button is on. The
doc.findPageForAnnotationRef(acroField.ref)
works for these types (PDFAcroText
,PDFAcroCheckBox
,PDFAcroComboBox
) but not forPDFAcroRadioButton
- returnsundefined
- I tried on multiple PDF forms.Is this by design or a bug? How do I find what page the radio button is on?
How did you attempt to do it?
What actually happened?
The API returned
undefined
What did you expect to happen?
The API would return an instance of
PDFPage
that the Radio button field is on like all other field types.How can we reproduce the issue?
Here's a codesandbox (Relevant code is in
CombinePDF.tsx
file): https://codesandbox.io/p/github/human-tools/toolbox-web/draft/elegant-maxwell?create=true&file=%2Fsrc%2FCombinePDF%2FCombinePDF.tsx&selection=%5B%7B%22endColumn%22%3A49%2C%22endLineNumber%22%3A7%2C%22startColumn%22%3A49%2C%22startLineNumber%22%3A7%7D%5DIn the open
CombinePDF.tsx
you'll see a upload field and once you upload a PDF with a form and radio buttons, you'll see in the console a print of all fields and the page found through thedoc.findPageForAnnotationRef
API. Notice that both the radio and pushbutton fields have undefined for their pages while the rest get the correct page.Attached PDF samples with a form and radio buttons. form_sample_pdf.pdf Purchase_Order_Form.pdf lobbyguardform_Sample.pdf
Version
^1.17.1
What environment are you running pdf-lib in?
Browser
Checklist
Additional Notes
No response