Extract FDF data in a memory buffer

Q: We are trying to persist the form data from PDF in a database in
order to facilitate later retrieval by the user for printing, etc.. We
don't want to take the user through document creation work flow again
nor save a file on disk.

How we are trying to Extract FDF info from the document and persist in
the database. Is there a way to achieve this?
A: Did you have a chance to take a look at FDF (Forms Data Format)
sample project (http://www.pdftron.com/net/samplecode.html#FDF)?

It shows how to extract FDF from PDF and merge FDF with PDF.

In case you want to save FDF format to memory or read it from memory
you can use the same technique (i.e. fdf.Save(mem_buffer)) used in
PDFDocMemory sample (http://www.pdftron.com/net/

Q: I had consulted those examples, however FDFDoc.Save only allows
saving to file not to memory stream. I could save to file, read it and
then create a stream out of it (as suggested in the samples) and then
store in db, but this is not a good option.

For now, I'm streaming the entire PDF document to the database
although this is not desirable as size of the doc far exceeds that of
the FDF. Is there an update available to PDFNet api that might allow
creating FDF streams? Sounds like a valuable enhancement.

A: The same approach applies to FDF doc. There are two versions of
FDFDoc.Save method. One accepts a filename, the other accepts a memory
buffer. You can use the latter version of FDFDoc.Save() method to
serialize the FDF in memory. For example:

// Extract data to FDF
try {
PDFDoc in_doc = new PDFDoc(output_path + "form1_filled.pdf");
FDFDoc doc = in_doc.FDFExtract();
// doc.SetPdfFileName("../form1.pdf");
byte[] buf = new byte[1];
int buf_sz = 1;
doc.Save(ref buf, ref buf_sz, SDFDoc.SaveOptions.e_remove_unused);
} catch (PDFNetException e) {

Q: I took your code above and plugged it in...and got a compile error:

Error 6 No overload for method 'Save' takes '3' arguments

VS 2005's intellisense shows only Save(string path) as the option
available when stubbing out this method.

I can see the second definition in your apiref.html that accompanied
the package but the compiler doesn't see it. If there are two versions
of FDFDoc.Save then its not in the version of the API we have. And we
have version 4. Is there a recent update available?
A: Sorry, the correct line is
  doc.Save(ref buf, ref buf_sz);

The second overlaod accepts only two parameters (i.e. not 3 like

To find out all of the object and methods available in PDFNet
for .NET double-click on ‘PDFNet’ located under ‘Refereces’ section
in your application solution. Then browse the namespace pdftron > FDF


Regarding VS2005 IntelliSense it is not a substitute for documentation
(i.e. in many cases it doesn't work as expected).