I successfully created a fillable form using PDF-lib (https://www.npmjs.com/package/pdf-lib).
But I am getting following error while flattening it.
Unhandled Rejection (Error): Failed to find page undefined for element mahesh_Signature_0
Here mahesh_Signature_0 is a text field name.
This is my simple code for flattening it.
const formPdfBytes = await fetch(file).then(res => res.arrayBuffer())
const pdfDoc = await PDFDocument.load(formPdfBytes)
const form = pdfDoc.getForm()
form.flatten()
How can I resolve this? Any alternate solution to flatten annotations of PDF in JavaScript?