Position of Textfields in a form

Position of Textfields in a form

Forum member · Nov 14, 2014
It's strange! I can't find a way to get the location (x,y) of a given TextField in a form. I can Access all fields by myDocument.Form.Fields[i] but I don't see a Methode or property to get the location of that item. Please help...

Re: Position of Textfields in a form

Support · Nov 14, 2014
Hello, You can retrieve the positions (X and Y) of the form fields using DynamicPDF Merger API. You will need to load the PDF document using PdfDocument class and use its GetX and GetY methods to get the X and Y positions. Below is the code sample for it. PdfDocument pdf = new PdfDocument(@"C:\Temp\Input.pdf"); MergeDocument document = new MergeDocument(pdf); //Retriveing the form field’s X, Y positions using PdfDocument object. int pageNumber=pdf.Form.Fields["form field name"].GetOriginalPageNumber(); Page page=document.Pages[pageNumber-1]; float xPosition = pdf.Form.Fields["form field name "].GetX(page); float yPosition = pdf.Form.Fields["form field name "].GetY(page); //Filling the form fields using MergeDocument object. document.Form.Fields["form field name "].Value = "MyValue"; document.Form.Output = ceTe.DynamicPDF.Forms.FormOutput.Flatten; document.Draw(@"C:\Temp\MyDocument.pdf"); Thanks, ceTe Software Support Team.