Click or drag to resize

Forms Data Format

This topic contains the following sections:

Overview

FDF is a file format for representing form data and annotations that are contained in a PDF form. It is a simplified file format based on the Adobe PDF document format. It allows creating form data, submitting structured form data to a server, receiving a response from the server and populating the form (in a PDF document) with the inquiry result.

Simply put, FDF is a tool to manipulate forms used in PDF documents.

To export form data to a FdfDocument, please use function PdfInteractiveFormsExportToFdf. This function exports data from a form to the FDF document. Basically, this function takes a PDF document with a form, fetches all data from this form and exports them to the FDF document.

To import form data from a FDF document, please use function PdfInteractiveFormsImportFromFdf. This function does the opposite: it imports the data from the specified FDF document to the PDF object.

Open in full size

fdf
How to export the form data in a PDF to a memory stream
C#
using (var doc = PdfDocument.Load("sample.pdf", new PdfForms()))
{
    doc.FormFill.ForceToKillFocus();

    using (var fdf = doc.FormFill.InterForm.ExportToFdf(null))
    {
        string content = fdf.Content;

        var data = System.Text.Encoding.UTF8.GetBytes(content);
        _memStream = new MemoryStream(data);
    }
}
How to import form data from a memory stream
C#
using (var doc = PdfDocument.Load("sample.pdf", new PdfForms()))
{
    using (var fdf = FdfDocument.Load(_memStream))
    {
        doc.FormFill.InterForm.ImportFromFdf(fdf);
    }
}
See Also