Form Data Extraction
The namespace TXTextControl.DocumentServer.PDF provides access to PDF elements and can be used to extract form data from completed PDF forms.
The following JSON contains all form fields of the PDF document on the right. The data is extracted server-side without any UI.
This demo uses the MVC version of TXTextControl.Web.MVC.DocumentViewer included in TX Text Control .NET Server for ASP.NET. The functionality is compatible across all supported platforms.
Version 33.0
Sample Source Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row"> | |
<div class="col-4"> | |
<!-- Info area --> | |
<div class="alert alert-info mt-3" role="alert"> | |
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> | |
<span class="alert-text"></span> | |
</div> | |
<button onclick="Extract()" class="btn mt-3 btn-success">Extract Data</button> | |
<p class="mt-5">Extracted Form Fields</p> | |
<div id="jsonEditor"></div> | |
</div> | |
<div class="col-8"> | |
<div class="tx-container"> | |
@Html.TXTextControl().DocumentViewer(settings => { | |
settings.DocumentPath = Server.MapPath("~/App_Data/Documents/vendor_completed.tx"); | |
settings.Dock = DocumentViewerSettings.DockStyle.Fill; | |
settings.IsSelectionActivated = false; | |
settings.ShowThumbnailPane = false; | |
}).Render() | |
</div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet] | |
public string PDFExtractData() { | |
string output = ""; | |
// create temporary ServerTextControl | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
TXTextControl.DocumentServer.PDF.AcroForms.FormField[] acroForms = | |
Forms.GetAcroFormFields(Server.MapPath("~/App_Data/Documents/vendor_completed.pdf")); | |
output = JsonConvert.SerializeObject(acroForms); | |
} | |
// return as Base64 encoded string | |
return output; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Extract(download) { | |
$('.alert .alert-text').text("Extracting form data. Please wait..."); | |
$('.alert').show(); | |
var bDocument; | |
var serviceURL = "@Url.Action("PDFExtractData", "TX")"; | |
// send document to controller | |
$.ajax({ | |
type: "GET", | |
url: serviceURL, | |
success: successFunc, | |
error: errorFunc | |
}); | |
function successFunc(data, status) { | |
editor.setValue(JSON.stringify(JSON.parse(data), null, 2)); | |
$('.alert').hide(); | |
} | |
function errorFunc() { | |
alert("Error"); | |
} | |
} |
No code required.
© 2025 Copyright Text Control GmbH and Text Control, LLC. All rights reserved. We ♥ documents.