解决方法
经过进一步审查,该领域的裁决被推翻.原来,如果您形成平坦的压模,字段不显示在生成的文档(因为它们缺乏“外观”设置). BTW,形状平整防止形式字段的进一步编辑.现在我们可以将外观添加到窗体中,但是更简单的方法是使用TextField类,而不用担心明确设置“外观”对象.
public void ABetterWayToAddFormFieldToExistingPDF( ) { PdfReader reader = new PdfReader(@"c:\existing.pdf"); FileStream out = new FileStream(@"C:\existingPlusFields.pdf",FileMode.Create,FileAccess.Write); PdfStamper stamp = new PdfStamper(reader,out); TextField field = new TextField(stamp.Writer,new iTextSharp.text.Rectangle(40,500,360,530),"some_text"); // add the field here,the second param is the page you want it on stamp.AddAnnotation(field.GetTextField(),1); stamp.FormFlattening = true; // lock fields and prevent further edits. stamp.Close(); }