PDFSign.js 是一个用于在浏览器中签名 PDF 文档的 JavaScript 库

PDFSign.js 是一个用于在浏览器中签名 PDF 文档的 JavaScript 库。签名只在浏览器中进行,且不会通过网络发送私钥或密码。

JavaScript 其它杂项

访问GitHub主页

共88Star

详细介绍

PDFSign.js

This library is not actively maintained anymore. There is a more active project to sign PDFs: https://github.com/vbuch/node-signpdf

PDFSign.js is a JavaScript library that signs a PDF in the browser. No private keys or passwords are ever sent over the network. The signing takes place in the browser only. The API is very simple:

signed-pdf = PDFSIGN.signpdf(pdf, p12-cert, p12-cert-password);

An example site is located in src/html. In this example, one can set the certificate (e.g., support/mycert-1-alt.p12), set the password "1234", and add a PDF file. The PDF will be signed with the certificate and the Adobe Reader will show that the PDF is signed but not trusted (its a self signed certificate). The button 'Create a PDF and output base64' takes a base64 encode file and outputs a base64 document in the browser, which immediately displays the PDF.

PDFSign uses two external libraries: forge and PDF.js.

Forge

The signing part is done with forge. This library had to be adapted as a PDF requires a detached pkcs7 signature as described here. Forge can handle pkcs7, however, always adds the content as well. The patch adds the feature to sign detached, similar as done here.

PDF.js

The PDF parsing is done with PDF.js. This library had also to be adapted as for writing PDF, offsets needed to be stored as well. This library was also stripped down to the parsing part, as the displaying part is not needed. Unfortunately, this was not only done on a file basis, but inside some files, displaying and parsing was mixed and had to be removed.

License

This software is released under the MIT license.