I have a process that inserts a table of content into an existing Acroform, and I am able to track where I need to start that content. However, I have existing Acrofields below that point that will need to be moved up or down, based on the height of the tables I insert. With that, how can I change the position of an Acrofield? Below is code that I can use to "get" the position...but now I also need to be able to "set" it.
....
// Initialize Stamper ("output" is a MemoryStream object)
PdfStamper stamper = new PdfStamper(pdf_rdr, output);
// Get Reference to PDF Document Fields
AcroFields fields = stamper.AcroFields;
//call method to get the field's current position
AcroFields.FieldPosition pos = GetFieldPosition(fields, "txt_footer");
// ** NEED TO EXPLICITLY SET A NEW POSITION FOR THE FIELD HERE
//assuming a call to "RegenerateField" will be required
fields.RegenerateField(txt_footer);
....
//helper method for capturing the position of a field
private static AcroFields.FieldPosition GetFieldPosition(AcroFields fields, string field_nm)
{
////////////////////////////////////////////////////////////////////////////////////
//get the left margin of the page, and the "top" location for starting positions
//using the "regarding_line" field as a basis
IList<AcroFields.FieldPosition> fieldPositions = fields.GetFieldPositions(field_nm);
AcroFields.FieldPosition pos = fieldPositions[0];
return pos;
}