0

由于某种原因,我无法将 PdfFormField 值发送到我的服务器。当我单击提交按钮时,它只会将使用 Acrobat 创建的字段中的数据发送到服务器,而不是使用 iTextSharp 以编程方式创建的字段。我正在使用 c#。

这就是我创建文本字段的方式:

Rectangle rec = new Rectangle(x, y-h, x+w, y);
cb.SaveState();
PdfGState state = new PdfGState();

cb.SetGState(state);
state.FillOpacity = opac;
state.StrokeOpacity = bopac;
cb.Rectangle(x, y - h, w, h);
cb.FillStroke();
cb.RestoreState();

这是我的提交按钮:

PdfContentByte cb = writer.DirectContent;
                Rectangle _rect;
                PdfFormField _Field1;

                _rect = new Rectangle(25, 15, 120, 40);
                PushbuttonField button = new PushbuttonField(writer, _rect, "Button0");
                button.BackgroundColor = new GrayColor(0.75f);
                button.BorderColor = GrayColor.GRAYBLACK;
                button.BorderWidth = 1;
                button.BorderStyle = PdfBorderDictionary.STYLE_BEVELED;
                button.TextColor = GrayColor.GRAYBLACK;
                button.FontSize = 12;
                button.Text = "Confirm Order";
                button.Layout = PushbuttonField.LAYOUT_ICON_LEFT_LABEL_RIGHT;
                button.ScaleIcon = PushbuttonField.SCALE_ICON_ALWAYS;
                button.ProportionalIcon = true;
                button.IconHorizontalAdjustment = 0;
                _Field1 = button.Field;
                int flags = PdfAction.SUBMIT_XFDF | PdfAction.SUBMIT_INCLUDE_NO_VALUE_FIELDS;
                _Field1.Action = PdfAction.CreateSubmitForm(@"http://127.0.0.1/index.php", null, flags);
                writer.AddAnnotation(_Field1);
4

1 回答 1

0

您没有在上面的代码中创建表单域,而只是创建了一个矩形。查看TextField

writer.AddAnnotation(new iTextSharp.text.pdf.TextField(writer, rect, "FirstName").GetTextField());
于 2013-04-09T13:58:55.837 回答