Import FDF format annotations to PDF via C#

Contents
[ ]

PDFAnnotationEditor class contains method to work with import of annotations from FDF file. PdfAnnotationEditor.ImportAnnotationsFromFdf method provides the functionality to import annotations from a FDF document to PDF file.

Also, Class Form include the Form.ImportFdf method - imports the content of the fields from the FDF file and put them into the new PDF.

The following code snippet shows you how to Import FDF format annotations to PDF with Form.ImportFdf() method:


    var fdfPath = Params.InputPath + "test.fdf";
    var templatePath = Params.InputPath + "Empty.pdf";
    var outputPath = Params.OutputPath + "test_form.pdf";

    using (var form = new Aspose.Pdf.Facades.Form(templatePath))
    {
        using (var fdfInputStream = new FileStream(fdfPath, FileMode.Open))
        {
            form.ImportFdf(fdfInputStream);
        }

        form.Save(outputPath);
    }

The next code snippet shows how to import FDF format annotations to PDF with PdfAnnotationEditor.ImportAnnotationsFromFdf() method:


    var fdfPath = Params.InputPath + "test.fdf";
    var templatePath = Params.InputPath + "Empty.pdf";
    var outputPath = Params.OutputPath + "test_annEditor.pdf";

    var editor = new PdfAnnotationEditor();
    editor.BindPdf(new Document(templatePath));
    editor.ImportAnnotationsFromFdf(fdfPath);
    editor.Save(outputPath);