使用Python对PDF文档进行数字签名 [英] Sign PDF documents digitally with Python

查看:1495
本文介绍了使用Python对PDF文档进行数字签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Python对PDF文档进行签名,并发现了一个名为 MyPDFSigner 的东西.

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

它有很好的文档,但是我发现文档有点混乱. 我唯一的问题是如何安装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)

是否有人已经尝试过该工具并对我有任何建议?或者,如果您知道其他签名PDF文件的Python库,请告诉我.

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.

谢谢.

推荐答案

文档说:

在Windows中,将文件mypdfsigner.pyd"C:\Program Files\MyPDFSigner"复制到C:\Python27\Lib\site-packages.

它还说您需要将安装添加到您的路径:

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

要在Windows中运行该示例,请在环境PATH变量中添加"C:\ Program Files \ MyPDFSigner"

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

此外,您必须先对其进行配置:

Additionally, you must configure it first:

在使用任何扩展名之前,有必要从图形应用程序开始为密钥存储和要使用的别名创建配置文件.该应用程序会在您的主目录中创建一个.mypdfsigner文件.

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.

这篇关于使用Python对PDF文档进行数字签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆