title: Issue while flattening PDF using PDF-lib in JavaScript
body: <p>I successfully created a fillable form using <strong>PDF-lib</strong> (<a href="https://www.npmjs.com/package/pdf-lib" rel="nofollow noreferrer">https://www.npmjs.com/package/pdf-lib</a>).</p>
  <p>But I am getting following error while flattening it.</p>
  <blockquote>
  <p>Unhandled Rejection (Error): Failed to find page undefined for element mahesh_Signature_0</p>
  </blockquote>
  <p>Here <em>mahesh_Signature_0</em> is a text field name.</p>
  <p>This is my simple code for flattening it.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const formPdfBytes = await fetch(file).then(res =&gt; res.arrayBuffer())
  const pdfDoc = await PDFDocument.load(formPdfBytes)
  const form = pdfDoc.getForm()
  form.flatten()</code></pre>
  </div>
  </div>
  </p>
  <p>How can I resolve this? Any alternate solution to flatten annotations of PDF in JavaScript?</p>