title: Sign PDF with plain JavaScript
body: <p>With WebCrypto API evolving and being supported by Chrome and Firefox, I would like to use it for digitally signing a PDF document. There is not much of literature around, but I found some examples [1] and a library called PKI.js [2]. In the examples, the signing process is described, but in the end, a signature is returned. I would expect my Base64 PDF file returned again in a signed Base64 string, but sadly, this is not what happens. PKI.js too, to my knowledge, does not provide a way to sign my Base64 PDF.</p>
  
  <p>Is there a way to sign a PDF with JavaScript and the WebCrypto API only? The private key can be entered in a <code>&lt;textarea&gt;</code> or, even better, stored in the certificate settings of the browser.</p>
  
  <p>Base64 PDF (from REST API) &rarr; Sign with JS &amp; certificate &rarr; Signed Base64 PDF (send to REST)</p>
  
  <ul>
  <li>[1] <a href="https://github.com/diafygi/webcrypto-examples" rel="noreferrer">https://github.com/diafygi/webcrypto-examples</a></li>
  <li>[2] <a href="https://pkijs.org/" rel="noreferrer">https://pkijs.org/</a></li>
  </ul>