基于iTextSharp创建不可编辑且支持数字签名的PDF问题
PDF加密后无法添加数字签名,需实现只读且允许客户签名
我目前使用EncryptPdfData方法加密PDF数据,原本期望实现PDF只读且支持数字签名,但尝试签名时触发以下错误:
当前文档不允许创建新签名,原因:
PDF权限字典不允许在用户访问模式下修改或创建包括签名域在内的交互式表单字段!
我的需求是:生成一份不可编辑内容的PDF提供给客户,同时允许客户在线添加数字签名(签名操作不能修改原文档内容)。
当前使用的C#代码如下:
private byte[] EncryptPdfData(byte[] pdfData) { // Create a memory stream to work with the PDF data using (MemoryStream ms = new MemoryStream()) { // Create a PdfReader to read the existing PDF data using (PdfReader reader = new PdfReader(pdfData)) { // Create a PdfStamper to modify the PDF using (PdfStamper stamper = new PdfStamper(reader, ms)) { // Set encryption options stamper.SetEncryption(null, // User password (empty means no password) null, // Owner password (empty means no password) PdfWriter.ALLOW_PRINTING | PdfWriter.ALLOW_MODIFY_ANNOTATIONS, // Permissions (allow printing and modify annotations) PdfWriter.ENCRYPTION_AES_128); // Encryption strength // Ensure the changes are applied stamper.Close(); } } // Return the encrypted PDF data return ms.ToArray(); } }
内容的提问来源于stack exchange,提问作者serbian_warrior
相关产品推荐
相关产品推荐

