Django Endesive PDF数字签名实用程序。
django-endesive的Python项目详细描述
Django Endesive PDF数字签名实用程序。此软件包允许您对来自Django的PDF文档进行数字签名 申请。它基于https://github.com/m32/endesive
为了对pdf文档进行数字签名,您需要一个有效的p12/pfx证书。您可以使用自签名 用于测试目的的证书,但您应该从证书颁发机构获取用于生产的证书。
合作伙伴在AATL上颁发的特殊pdf证书 (Adobe批准的信任列表)。
文档
快速启动
安装django endesive:
pip install django-endesive
将其添加到已安装的应用程序中
INSTALLED_APPS=(...'django_endesive.apps.DjangoEndesiveConfig',...)
在settings.py文件中添加以下设置:
DJANGO_ENDESIVE={'PDF_CERTIFICATE_PATH':'required: /path/to/your/certificate','PDF_CERTIFICATE_PASSWORD':'optional: certificate password if applicable','PDF_ATTRIBUTES':{'CONTACT':'optional: <you@example.com>','LOCATION':'optional: <your location>','REASON':'optional: <Reason for Document validation>'}}
下面是一个相当做作的例子,说明如何在pdf上签名:
fromdjango_endesiveimportpdffromendesive.pdfimportfpdf# Generate a pdf file (this could be any file already generated by your app)doc=fpdf.FPDF()doc.add_page()doc.set_font('helvetica','',13.0)doc.cell(w=75.0,h=22.0,align='C',txt='Hello, world page=1.',border=0,ln=0)doc.output('./pdf.pdf',"F")# Open file and feed bytes to the sign functionpdf_bytes=open('./pdf.pdf','rb').read()signed_pdf=pdf.sign(pdf_bytes=pdf_bytes)# signed_pdf bytes can now be written to a bytestream in memory or saved to a file on disk
运行测试
代码真的有用吗?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
历史记录
0.1.0(2018-12-04)
- pypi上的第一个版本。