DaveB's answer works, but the problem is that you need to know the coordinates to place the text box, (67, 585, 140, 800). A more common way to do this is to create a table cell and add a custom event to the cell. When table generation raises the celllayout event, it passes the cell sizes and coordinates to it, which you can use to place and size the text field.
First create this call, which is a custom event
public class CustomCellLayout : IPdfPCellEvent { private string fieldname; public CustomCellLayout(string name) { fieldname = name; } public void CellLayout(PdfPCell cell, Rectangle rectangle, PdfContentByte[] canvases) { PdfWriter writer = canvases[0].PdfWriter;
Then, in your code where you create the table, you will use this event as follows:
PdfPCell cell = new PdfPCell() { CellEvent = new CustomCellLayout(fieldname) // set borders, or other cell options here };
If you want to use different types of text fields, you can either create additional custom events or add additional properties to the CustomCellLayout class, for example, "fontsize" or "multiline", which you would set using the class constructor, and then check in the CellLayout code to set text box properties.
Jeff s
source share