Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用iTextSharp在PDF阅读器中启用保存选项_C#_.net_Pdf_Itextsharp - Fatal编程技术网

C# 使用iTextSharp在PDF阅读器中启用保存选项

C# 使用iTextSharp在PDF阅读器中启用保存选项,c#,.net,pdf,itextsharp,C#,.net,Pdf,Itextsharp,我使用iTextSharp开发了一个可编辑的PDF 我的代码是: //Creating a document Document document = new Document(PageSize.A4, 50, 50, 25, 25); FileStream pdfFileStream = new FileStream("D:\\new.pdf", FileMode.Create); //Writing to PDF using (PdfWrit

我使用iTextSharp开发了一个可编辑的PDF

我的代码是:

//Creating a document
        Document document = new Document(PageSize.A4, 50, 50, 25, 25);

        FileStream pdfFileStream = new FileStream("D:\\new.pdf", FileMode.Create);

//Writing to PDF
        using (PdfWriter pdfWriter = PdfWriter.GetInstance(document, pdfFileStream))
        {
            //Opening the document for writing
            document.Open();
            PdfContentByte cb = pdfWriter.DirectContent;

            Paragraph para = new Paragraph("Name");
            document.Add(para);

            //Creating the text box starts here --->
            TextField _text = new TextField(pdfWriter, new Rectangle(100, 806, 170, 790), "Name");
            _text.BackgroundColor = BaseColor.LIGHT_GRAY;
            _text.Alignment = Element.ALIGN_CENTER;
            //_text.Options = TextField.MULTILINE;
            _text.Text = "";
            pdfWriter.AddAnnotation(_text.GetTextField());
            cb = pdfWriter.DirectContent;

            //Creating the text box ends here ---<

            //Creating the RadioButton group starts here ---->

            PdfFormField _radioGroup = PdfFormField.CreateRadioButton(pdfWriter, true);
            _radioGroup.FieldName = "Gender";

            string[] genders = { "Male", "Female" };

            RadioCheckField genderRadioCheckField;
            PdfFormField radioGField;

            for (int i = 0; i < genders.Length; i++)
            {
                genderRadioCheckField = new RadioCheckField(pdfWriter, new Rectangle(40, 806 - i * 40, 60, 788 - i * 40), null, genders[i]);

                genderRadioCheckField.BackgroundColor = BaseColor.LIGHT_GRAY;
                genderRadioCheckField.CheckType = RadioCheckField.TYPE_CIRCLE;

                radioGField = genderRadioCheckField.RadioField;
                ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase(genders[i], new Font(Font.FontFamily.HELVETICA, 12)), 70, 790 - i * 40, 0);
                _radioGroup.AddKid(radioGField);

            }

            pdfWriter.AddAnnotation(_radioGroup);
            cb = pdfWriter.DirectContent;
            //Creating the RadioButton group ends here ----<



            //Closing the document for writing
            document.Close();

            Console.WriteLine("Completed");
            Console.ReadLine();

        }
//创建文档
文件=新文件(PageSize.A4、50、50、25、25);
FileStream pdfFileStream=newfilestream(“D:\\new.pdf”,FileMode.Create);
//写入PDF
使用(PdfWriter PdfWriter=PdfWriter.GetInstance(文档,pdfFileStream))
{
//打开文档进行写作
document.Open();
PdfContentByte cb=pdfWriter.DirectContent;
段落段落=新段落(“名称”);
文件.增补(第6段);
//从这里开始创建文本框--->
TextField_text=newtextfield(pdfWriter,新矩形(100806170790),“Name”);
_text.BackgroundColor=BaseColor.LIGHT\u GRAY;
_text.ALIGN=Element.ALIGN\u CENTER;
//_text.Options=TextField.MULTILINE;
_text.text=”“;
pdfWriter.AddAnnotation(_text.GetTextField());
cb=pdfWriter.DirectContent;
//创建文本框到此结束---<
//创建RadioButton组从这里开始---->
PdfFormField _radioGroup=PdfFormField.CreateRadioButton(pdfWriter,true);
_radioGroup.FieldName=“性别”;
字符串[]genders={“男”,“女”};
RadioCheckField genderRadioCheckField;
PdfFormField;
for(int i=0;i
现在,代码生成带有文本字段和单选按钮的可编辑PDF

问题是:

我使用Adobe Reader打开生成的PDF文件,并在
文本字段中输入一些文本,然后试图保存它

我在文件菜单下找不到任何保存选项,但我也尝试使用另存为-->PDF,它将消息显示为:

除非您使用的是Adobe Acrobat X standard、Adobe Acrobat X pro、Adobe Acrobat X knowledge worker suite,否则此文档不允许您保存对其所做的任何更改。您将只保存文档的副本。是否继续

如何在Adobe PDF Reader中启用保存选项?。我的C代码有问题吗?

您想启用PDF阅读器。阅读器启用涉及使用Adobe拥有的私钥添加数字签名。当Adobe Reader检测到该签名且签名有效时,Adobe Reader将解锁仅在Adobe Acrobat中可用的功能(取决于您在签署文档时定义的使用权限)

你的C#没有问题。主要问题是,您请求的功能需要访问Adobe拥有的私钥。
没有第三方产品被授予访问该密钥的权限。您只能使用Adobe软件启用PDF文档的读卡器。iText、iTextSharp或Adobe产品以外的任何其他软件启用文档阅读器都是非法的

总结:您要求的功能仅在使用Adobe软件时可用。不允许任何第三方供应商提供该功能(除非他们从Adobe获得许可证)。

您想启用PDF阅读器。阅读器启用涉及使用Adobe拥有的私钥添加数字签名。当Adobe Reader检测到该签名且签名有效时,Adobe Reader将解锁仅在Adobe Acrobat中可用的功能(取决于您在签署文档时定义的使用权限)

你的C#没有问题。主要问题是,您请求的功能需要访问Adobe拥有的私钥。没有第三方产品被授予访问该密钥的权限。您只能使用Adobe软件启用PDF文档的读卡器。iText、iTextSharp或Adobe产品以外的任何其他软件启用文档阅读器都是非法的


总结:您要求的功能仅在使用Adobe软件时可用。不允许任何第三方供应商提供该功能(除非他们有Adobe的许可证)。

解决方案:


我使用了Adobe Reader X,如果我们使用
iTextSharp.dll
,它不支持保存选项。最后,我下载了AdobeReaderDC的最新版本,它运行良好。现在,我可以编辑和保存我的文档了。感谢所有其他回复。

解决方案:


我使用了Adobe Reader X,如果我们使用
iTextSharp.dll
,它不支持保存选项。最后,我下载了AdobeReaderDC的最新版本,它运行良好。现在,我可以编辑和保存我的文档了。感谢所有其他回复。

尝试使用打印到磁盘的BullZIP PDF打印机

尝试使用打印到磁盘的BullZIP PDF打印机

您尝试过更新的Adobe Re吗