Retrieving Form Field location in PDF (.NET Core/Framework)
Retrieving Form Field location in PDF using DynamicPDF Merger is simple and easy.
How to Retrieve Form Fields in C#
The following steps and sample code illustrate retrieving Form Field location in PDF using DynamiicPDF Core Suite.
Steps for Retrieving Form Field Location in PDF
- Create a
PdfDocument
object with the desired pdf. - Create a
MergeDocument
object with the desired pdf. - Create a
Page
and add it to the MergeDocument instance. - Create a
Image
object. - Set the height and width of image with
PdfDocument
form field's height and width respectively. - Add the image to the Page instance.
- Save the MergeDocument instance.
Sample Code - C#
PdfDocument pdfDocument = new PdfDocument("myDocument.pdf");
MergeDocument document = new MergeDocument("output.pdf", MergeOptions.None);
Page page = document.Pages[0];
Image image = new Image("image.gif", 0, 0);
image.X = pdfDocument.Form.Fields["PlaceHolderField"].GetX(page);
image.Y = pdfDocument.Form.Fields["PlaceHolderField"].GetY(page);
image.Height = pdfDocument.Form.Fields["PlaceHolderField"].Height;
image.Width = pdfDocument.Form.Fields["PlaceHolderField"].Width;
page.Elements.Add(image);
document.Draw(@"Output.pdf");
Getting Started
NuGet Package
DynamicPDF Core Suite is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET
package. The easiest way to install the package is through the Visual Studio Package Manager. You can also download the package directly from NuGet.
DynamicPDF Core Suite Information
More information can be found on the DynamicPDF Core Suite webpage.
Available on Other Platforms
DynamicPDF Core Suite is available for the Java and COM/ActiveX platforms. Refer to the respective product pages for more details.
- Java - DynamicPDF Generator for Java
- COM/ActiveX - DynamicPDF Generator for COM/ActiveX