Sign PDF documents digitally with Python

流过昼夜 提交于 2019-12-19 04:06:26

问题


I am trying to sign PDF documents with Python and found something called MyPDFSigner.

It is well documented, however I found the documentation a bit confusing. The only problem I am having is on how to install the mypdfsigner module to run the code to sign a document.

The documentation itself provided a code sample but while the module isn't installed I won't be able to run it:

inputPath = "/tmp/input.pdf"
outputPath = "/tmp/output.pdf"
location = "Chicago, Illinois"
reason = "Demo"
contactInfo = "+1 555-555-5555"
certify = True
visible = True
title = "Signing with MyPDFSigner"
author = "KryptoKoder"
subject = "Python Extension"
keywords = "PKCS#12, PDF, MyPDFSigner"
confFile = ""   # defaults to /usr/local/mypdfsigner/mypdfsigner.conf if empty
timestamp = True

print mypdfsigner.sign(inputPath, outputPath, location, reason, contactInfo, certify, visible, title, author, subject, keywords, confFile, timestamp)

Does anyone already tried this tool and have any advice for me? Or if you know any other Python library that signs PDF files please tell me.

Thanks.


回答1:


The documentation says:

In Windows copy the file mypdfsigner.pyd from "C:\Program Files\MyPDFSigner" to C:\Python27\Lib\site-packages.

It also says you need to add the installation to your path:

To run the example in Windows add "C:\Program Files\MyPDFSigner" to the environment PATH variable

Additionally, you must configure it first:

Before using any of the extensions it is necessary to start with the graphical application to create a configuration file for the key store and alias one wants to use. The application creates a .mypdfsigner file in your home directory.



来源:https://stackoverflow.com/questions/29629410/sign-pdf-documents-digitally-with-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!