我正在尝试在使用iTextSharp的段落句子中添加一个TextField(acrofield)。一个例子是“生效日期是[Month],[Year]的[Day]日,这将开始。”将PPCPCell添加到段落
事情我已经尝试:
Paragraph para1 = new Paragraph();
para1.Add(New Phrase("The Effective Date is",fontBold));
//The next line is where it breaks, "Insertion of illegal Element: 30"
para1.Add(CreateTextField("Day",1,0)); //this function returns a PdfPCell.
PdfPCell tempCell = new PdfPCell();
tempCell.AddElement(new Phrase("The Effective Date is",fontBold));
//the next line breaks as well, "Element not allowed."
tempCell.AddElement(CreateTextField("Day",1,0));
Paragraph para1 = new Paragraph();
para1.Add(New Phrase("The Effective Date is",fontBold));
para1.AddSpecial(CreateTextField("Day",1,0));
//This doesn't generate an error, but the TextField is not displayed on PDF
Paragraph para1 = new Paragraph();
PdfPTable tempTable = new PdfPTable(1);
para1.Add(New Phrase("Hello",fontBold));
tempTable.AddCell(CreateTextField("Day",1,0));
para1.Add(tempTable);
para1.Add(New Phrase("World",fontBold));
//This doesn't generate an error, but the TextField is not displayed on PDF
我知道,通过createTextField(...)的作品,因为我在使用它其他几个地方在页面上。
如何在不使用表格的情况下将TextField与其他文本内嵌添加,并且繁琐地尝试操纵单元格大小以适应我需要的内容?
感谢您的帮助!
这是个多么奇怪的问题。 “PdfPCell”是“PdfPRow”的一部分,而“PdfPRow”又是“PdfPTable”的一部分。我想不出为什么有人想为'Paragraph'添加一个'PdfPCell'。你想要达到的目标可以很容易完成,但不能用“PdfPCell”。你的问题听起来像“我用叉子吃汤,这是行不通的。”这个问题的答案是:“不要使用叉子(也不要责怪叉子),使用勺子。” –
取决于你喜欢你的汤。 :P –