Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active December 23, 2020 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/b64b2266ab7018b43e07dfa41aaa7cad to your computer and use it in GitHub Desktop.
Save GroupDocsGists/b64b2266ab7018b43e07dfa41aaa7cad to your computer and use it in GitHub Desktop.
Parse PDF forms and extract field values
// Parse the filled PDF Form to extract field values in C#
using (Parser parser = new Parser("filePath/PDFForm.pdf"))
{
// Extract data from PDF Form
DocumentData data = parser.ParseForm();
// Iterate over the extracted PDF Form fields data
for (int i = 0; i < data.Count; i++)
{
Console.Write(data[i].Name + ": ");
PageTextArea area = data[i].PageArea as PageTextArea;
Console.WriteLine(area == null ? "Not a template field" : area.Text);
}
}
// Parse the filled PDF Form to extract field values using Java API of GroupDocs.Parser
Parser parser = new Parser("filePath/PDFForm.pdf");
// Extract data from PDF Form
DocumentData data = parser.parseForm();
// Iterate over the extracted PDF form data
for (int i = 0; i < data.getCount(); i++) {
System.out.print(data.get(i).getName() + ": ");
PageTextArea area = (data.get(i).getPageArea() instanceof PageTextArea)
? (PageTextArea) data.get(i).getPageArea()
: null;
System.out.println(area == null ? "Not a template field" : area.getText());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment