I'm trying to generate a pdf and fill in some fields at the same time. I do this two ways. The first by creating a text field and setting the text.
var _text = new TextField(writer,
new Rectangle(sectionX + textLength + 2, fieldIncrementer - 3,
sectionX + Convert.ToSingle(xElement.Parent.Attribute("width").Value),
fieldIncrementer + fieldFontSize - 2), xElement.Attribute("name").Value.Trim());
if (xElement.Attribute("autoFill") != null)
{
_text.Text = FormAutoFill.Instance.GetValue(xElement.Attribute("autoFill").Value);
}
This works well. The other way is for creating a text field that sits on top of a cell in a table.
//Create the text field that will be attached to the cell
var tf = new TextField(writer, new Rectangle(67, 585, 140, 800),
tableDescendant.Attribute("name").Value); //The rectangle will be ignored by the cell event
tf.Alignment = alignment;
tf.Font = FONT;
if (tableDescendant.Attribute("autoFill") != null)
{
tf.Text = tableDescendant.Attribute("autoFill").Value;
}
//Create an empty phrase since the cell won't take an empty string
var phrase = new Phrase(" ",
new Font(FONT, FontSize, Font.NORMAL, BaseColor.BLACK));
//Create the empty cell
var tbCell = new PdfPCell(phrase);
var events = new FieldPositioningEvents(writer, tf.GetTextField());
events.AddField("djdjdj", tf.GetTextField());
tbCell.CellEvent = events;
This method works great when viewing the pdf through BlueBeam Revu, but in Adobe Reader, the fields that are in a table are not visible.
Even stranger, if I click the button on the top of reader that says "Highlight Existing Fields" I see the text that supposed to be there, but it's squashed!
I hope someone can help me out here, I see no difference between the first method and the second method.
UPDATE #1: It appears that the same behavior is exhibited in bluebeam after I print. That is, the text is squashed.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…