# Adobe FDF Tookit With C# / .NET

If you're providing users a PDF that requires them to type in or hand write information that you already have (ie. in a database), why not provide a PDF that has been dynamically pre-populated with this information instead?

Here's how to accomplish this using Adobe's FDF Toolkit and C# as I wasn't able to find a good source on how to build a similar app in C# when I was once in need. This guide assumes you have some familiarity working with .NET, C#, Acrobat, FDF (Form Data Form), and PDF.

1. Open an existing PDF or create a new file
2. Create a text field
3. Name it: fooField
4. Save your PDF as myfile.pdf
Setup FDF Toolkit

2. Copy the files fdfacx.dll and fdftk.dll to a folder on your web server, either a global folder or even your application's /bin folder.
3. From the Windows Command Prompt, type: regsvr32 c:\path\to\file\fdfacx.dll where path\to\file is the actual path to the file.
4. Use the Type Library Importer included with Visual Studio to create a CLR assembly. At the Command Prompt, type: tlbimp FdfAcX.dll /out:fdfacx_clr.dll (modify paths as necessary).
5. Place the newly created CLR assembly fdfacx_clr.dll in your .NET application's /bin folder.
C# Source Code
using fdfacx_clr; // include generated CLR assembly

private string foo;
foo = "bar";

FdfAppClass FdfAcX_App = new FdfAppClass();
FdfDoc outputFDF = (FdfDoc)FdfAcX_App.FDFCreate();

outputFDF.FDFSetFile("http://path/to/pdf/myfile.pdf"); // absolute web path to your pdf file
outputFDF.FDFSetValue("fooField", foo, false);
outputFDF.FDFSetStatus(foo + " will now be inserted into fooField");

Response.ContentType = "application/vnd.fdf";
Response.Write(outputFDF.FDFSaveToStr());
Response.End();
outputFDF.FDFClose();

That's it. Fire up your C# ASP.Net web application and navigate to your start page and it should create a FDF on the fly that will point to your PDF.

Forgive me if I've left anything out or made any errors as it's been awhile since I actually worked on the project. Leave a comment if you run into any problems!

Hi Tariq,

Just came across your article while browsing for fdf help. I was wondering if you cud answer a question for me. My boss is building a standalone windows app which has a bunch of forms gathering data (being stored as text) and I have to populate a ton of pdf forms usng this data. thought converting the text into FDF would be a good idea, but this app will hv to run on standalone machines (out in the field) with no connection to a server.
Can you think of a way to do this with the FDF toolkit?

Thanks much!

Dee

Dee - Friday May 1, 2009

Your example of populating a PDF from a database (above) is great. How can I get the data INTO the database?

Eugene Ross - Tuesday February 22, 2011

This is not working in ASP.Net 4.0 C#… anyone else getting odd errors when trying to add the DLL to the reference???

Jamie - Sunday November 20, 2011

I didn’t have a problem with adding the reference, rather the page simply did nothing when I navigated to it. No response, nothing.

.NET 4.0, IIS 7

Jeffrey - Friday January 6, 2012

Hi

I am receiving an error when using the example above. Error 1 The type or namespace name ‘fdfacx_clr’ could not be found (are you missing a using directive or an assembly reference?).

Thank you.

Rovlin Moodley - Wednesday June 6, 2012

Textile Help

## Hello

My name is Tariq. I am a twenty something website developer based in Toronto, Canada, working at kanetix doing what I love to do. Yeppers, I like turtles and get on (the TTC) daily.