I would like to capture filled PDF form data from public facing website and save it in the database on the server. Is it possible?Please let me know.
4 Answers
I would recommend looking into one of the PDF libraries such as iTextSharp. This entry will show you how to loop through all of the form fields in a PDF. And this entry will show you how to get fields by a given name.

- 1
- 1

- 53,986
- 12
- 141
- 274
-
Chris, Is it possible to email the filled form to specified email address with out prompting outlook? Thank you. – nav100 Sep 02 '11 at 14:18
-
I'm guessing you're only talking about Adobe Acrobat and/or Reader so the answer is no for emailing. Everyone's afraid of incorporating an SMTP engine in their program so they always rely on someone else which is why Outlook, OE, Entourage, etc, get invoked. You can either have the person upload the PDF manually or do as @Leons said. – Chris Haas Sep 02 '11 at 15:13
Yes, it is possible. You need a submit button on the form. In the properties of the submit button, select FDF as data type. Each field from the PDF document will have a name. Textbox1, Textbox2, etc. and you will receive name-value pairs. There are libraries available that will assist with processing the returned data.
I received the completed PDF document in my Controller (ASP.NET MVC application) as follows:
string filename = Path.Combine(Server.MapPath(rootPath), name);
using (FileStream fs = new FileStream(filename, FileMode.CreateNew))
{
byte[] bytes = new byte[8192];
int bytesRead;
while ((bytesRead = Request.InputStream.Read(bytes, 0, bytes.Length)) > 0)
{
fs.Write(bytes, 0, bytesRead);
}
}
In this case filename is a temporary filename located in a temp area (rootPath) where I have write access. Another solution will be to write the file to a MemoryStream and then use that to send in email.

- 2,679
- 1
- 21
- 25
-
Thanks. I will take a look. Is it possible to email the filled form directly after clicking on 'Submit' button on PDF. Right now when I click on 'Email Form' Submit button, it's trying to open outlook to send email. I would like to bypass and send directly to specified email address. – nav100 Sep 02 '11 at 14:16
-
I don't think that is possible. The last tab of the properties as all the actions that you can perform. The only one that I found usable is "Submit a form". So I chose to submit the filled in form to the server from where I can then send it via email. The Submit Form action has a couple of settings for receiving different content. I use PDF, but you can get FDF, HTML or XFDF also. Use the one that will work best for you. – Leons Sep 02 '11 at 14:42
-
Leons, Could you please explain more about submitting the filled form to the server and then send an email? Do I have to write some script? – nav100 Sep 06 '11 at 18:47
-
@nav100 - I am on IIS 7 and wrote C# code to receive the PDF and then send it via email using System.Net.Mail.MailMessage and SmtpClient. I will edit my anwer to show how I received the file. – Leons Sep 07 '11 at 00:01
You can use FDFToolkit.net to save PDF form submissions to a database:
Here's an example with ASP.net(VB.net), ADO.net, and SQL:
If Not IsPostBack Then
Dim fdfApp As New FDFApp.FDFApp_Class()
Dim fdfDoc As New FDFApp.FDFDoc_Class()
fdfDoc = fdfApp.FDFOpenFromStream(Request.InputStream, True, True)
Dim dr As DataRow
Dim ds As New DataSet
Dim da As New System.Data.SqlClient.SqlDataAdapter("SELECT * FROM TABLENAME", "CONNECTION STRING")
da.Fill(ds, "TABLENAME")
dr = ds.Tables(0).NewRow
'SET VALUES THAT MATCH NAMES IN TABLE & IN PDF
'fdfDoc.FDFSetDataRowFromValues(dr)
dr("FIELD_NAME1") = fdfDoc.FDFGetValue("PDF_FIELD_NAME1")
dr("FIELD_NAME2") = fdfDoc.FDFGetValue("PDF_FIELD_NAME2")
' DUMP XML FILE TO FIELD
dr("FIELD_DUMP_XML") = fdfDoc.FDFSavetoStr(FDFDoc_Class.FDFType.XML, True)
ds.Tables(0).Rows.Add(dr)
da.Update(ds, "TABLENAME")
fdfDoc.FDFClose()
fdfDoc.Dispose()
End If

- 1
-
1Please mention in the post that you're recommending your own product, otherwise it is possible that your posts might be flagged as spam. – Hans Olsson Jun 07 '12 at 22:24
To automatically send the filled data via e-mail you can do the following:
- Add a PDF Button ("Submit")
- Right-click -> PDF Options -> Field Properties
- Select "Action" Tab
- Select the Submit Form type
- in the url type mailto:mail.recipient@anymail.com
- In the submit format select FDF or the format you want
DONE!
When the user clicks it, it will automatically attach the datafile to the email. It will ask the user whether to use default email or webmail.
The FDF file you receive or any other format, will have to be parsed in order to extract the data.
I know this is old, but someone might be looking for this answer.

- 49
- 1
- 1
- 5