我正在使用 iTextSharp,但遇到了无法解决的问题。我正在加载一个现有的 PDF 表单,其中包含文本字段和复选框的混合体。我在将表单发送到浏览器之前动态添加一个提交按钮,在浏览器中填写表单然后重新提交到服务器。我的问题是我无法让 PDF 提交回所有已填充和空白的字段。我已经确定了应该返回所有字段的代码,但我无法返回空复选框。我现在认为这是不可能的。任何人使用使用 Acrobat Pro(而不是 LiveCycle)创建的 PDF Acroform 来执行此操作。请参阅下面的创建按钮的代码片段。我正在使用 iTextSharp 在 C# asp.net 4 中执行此操作。
ButtonRect = MakeButtonRect(PDFFormOut, ButtonPos);
button = new PushbuttonField(PDFFormOut.Writer, ButtonRect, "postSubmit");
button.BackgroundColor = BaseColor.LIGHT_GRAY;
button.BorderColor = GrayColor.BLACK;
button.BorderWidth = 1f;
button.BorderStyle = PdfBorderDictionary.STYLE_BEVELED;
button.TextColor = GrayColor.GREEN;
button.FontSize = 8f;
button.Text = "Submit";
button.Visibility = PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT;
field = button.Field;
field.Put(PdfName.TU, new PdfString("Save changes and return to the folder."));
**field.Action = PdfAction.CreateSubmitForm(@"http://" + Application["WebSiteRoot"].ToString() + @"/SaveForm.aspx?OP=SAV", null, PdfAction.SUBMIT_HTML_FORMAT | PdfAction.SUBMIT_INCLUDE_NO_VALUE_FIELDS);**
PDFFormOut.AddAnnotation(field, 1);
Run Code Online (Sandbox Code Playgroud)