我有一个将目录插入现有 Acroform 的过程,并且我能够跟踪我需要从哪里开始该内容。但是,我在该点下方有现有的 Acrofields,需要根据我插入的表格的高度向上或向下移动。有了这个,我怎样才能改变 Acrofield 的位置?下面是我可以用来“获取”位置的代码......但现在我还需要能够“设置”它。
……
// 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");
// ** 需要在此处明确设置字段的新位置
//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;
}