populate a web form using PDF form data

91 views Asked by At

How can I setup a website to access a completed PDF form (I provide the PDF form), and when uploaded, it uses the data from the fields to populate a web form?

There are many use cases for this, e.g. many governments or companies have long forms to fill in now on "modern" web forms on their website. This has to be behind a login, and if too much time passes, the user is logged out. Allowing the user to complete the form offline / at different times - without being put off by another login process - helps move the process forward. At completion then, the data can be mapped to the HTML form, and subsequently stored in an easily linked database.

1

There are 1 answers

0
Albert D. Kallal On BEST ANSWER

The free iTextSharp library is able to open a pdf and read all fields in that pdf.

So, assuming the user up-loads the pdf to the web site?

Then it is a simple matter to open the pdf, and pull/read all of the data fields, and then add them to a database table.

So, say this code:

    Dim strF As String = txtFile.Text
    Dim pdfRead As New PdfReader(strF)

    Dim OneField As KeyValuePair(Of String, AcroFields.Item)

    Dim pFieldList As AcroFields = pdfRead.AcroFields

    For Each OneField In pFieldList.Fields

        Debug.Print(OneField.Key & " -> " & pFieldList.GetField(OneField.Key).ToString())

    Next

Output:

enter image description here

So, it is not clear "where" the above output is to be saved, but I would have to guess/assume that such data would eventually be written out to a database which given the above code would be a rather trivial bit of code.