我的项目要求在PDF中绘制4个可编辑的textFields(签名),以便客户端可以在任一textFields中输入文本,并且该文本应该在表单上可见。
这里的问题是textFields是不透明的,顶部的textField隐藏了在它们之前绘制的所有textFields的文本。
任何解决方案或解决方法都会非常有用。
下面提到的是代码:
private void AddTextFieldsToPDF()
{
{
// The yOffset will move the text boxes above the signature line instead of somewhat on it.
//OwnerSignYPosition : Float containing y-axis position of textField
//Stacking one text field over other
AddTextField(_reportDocument.DocWriter, "Field1", "field1", true, 40, OwnerSignYPos, 380, 18);
AddTextField(_reportDocument.DocWriter, "Field2", "field2", true, 40, OwnerSignYPos, 380, 18);
AddTextField(_reportDocument.DocWriter, "Field3", "field3", true, 40, OwnerSignYPos, 380, 18);
AddTextField(_reportDocument.DocWriter, "Field4", "field4", true, 40, OwnerSignYPos, 380, 18);
}
}
protected void AddTextField(iTextSharp.text.pdf.PdfWriter writer, String fieldId, String fieldText, Boolean isSignature, float xPosition, float yPosition, float width, float height)
{
Rectangle position = new Rectangle(xPosition, yPosition, xPosition + width, Math.Max(yPosition - height, 0));
iTextSharp.text.pdf.TextField field = new iTextSharp.text.pdf.TextField(writer, position, text);
field.Text = fieldText;
field.Box.BackgroundColor = Color.BLACK;
field.Font = FontFactory.GetFont("Arial Narrow").BaseFont;
field.TextColor = Color.WHITE; //new Color(0, 0, 255); // White
field.FontSize = 9;
writer.AddAnnotation(field.GetTextField());
}
由于