Retrieving Form Field location in PDF in C# (.NET Core)

Retrieving Form Field location in PDF using DynamicPDF Merger is simple and easy.

How to retrieve Form Fields in C#

Below are the steps and sample code to retrieve Form Field location in PDF using the DynamicPDF Merger product.

Steps for Retrieving Form Field location in PDF

  1. Create a PdfDocument object with the desired pdf.
  2. Create a MergeDocument object with the desired pdf.
  3. Create a Page and add to the MergeDocument.
  4. Create a Image object.
  5. Set the height and width of image with PdfDocument form field's height and width respectively.
  6. add the image to the page.
  7. Save the MergeDocument.

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(@"C:\Output.pdf");  

Getting Started

NuGet Package

DynamicPDF Merger is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The Core Suite package includes Generator, Merger and ReportWriter.

Nuget Logo
NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

Example Project

An example project showing this functionality can be cloned or viewed from GitHub:

GitHub Logo
Clone or View Example Project on GitHub

DynamicPDF Merger Information

More information can be found here:

Available in Other Platforms

DynamicPDF Merger PDF Library is available for Java and COM/AxtiveX platforms. Refer to the respective product pages for more details.

Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 18 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!