Exporting interactive form fields from a PDF document is a common requirement in many applications. This process can be efficiently handled using the SautinSoft PDF .Net library. Below, we will explore how to achieve this using C# and .NET. Extraction form fields from a PDF document to a PDF.Net can be useful in various scenarios. Here are a few key reasons why this might be necessary.
Полный код
using System;
using System.IO;
using SautinSoft;
using SautinSoft.Pdf;
using SautinSoft.Pdf.Content;
namespace Sample
{
class Sample
{
/// <summary>
/// Export form fields data to fdf/xfdf/json document.
/// </summary>
/// <remarks>
/// Details: https://sautinsoft.com/products/pdf/help/net/developer-guide/export-interactive-forms.php
/// </remarks>
static void Main(string[] args)
{
// Before starting this example, please get a free 100-day trial key:
// https://sautinsoft.com/start-for-free/
// Apply the key here:
// PdfDocument.SetLicense("...");
string pdfFile = Path.GetFullPath(@"..\..\..\FormFilled.pdf");
using (var document = PdfDocument.Load(pdfFile))
{
//Export form data as fdf stream.
var fdfFile = new FileStream("..\\..\\..\\fdfOut.fdf", FileMode.Create);
document.Form.ExportData(fdfFile, SautinSoft.Pdf.Forms.PdfFormDataFormat.FDF);
//Export form data to xfdf file.
document.Form.ExportData("..\\..\\..\\xfdfOut.xfdf");
//Export form data to json file.
document.Form.ExportData("..\\..\\..\\jsonOut.json");
}
}
}
}
Option Infer On
Imports System
Imports System.IO
Imports SautinSoft
Imports SautinSoft.Pdf
Imports SautinSoft.Pdf.Content
Namespace Sample
Friend Class Sample
''' <summary>
''' Export form fields data to fdf/xfdf/json document.
''' </summary>
''' <remarks>
''' Details: https://sautinsoft.com/products/pdf/help/net/developer-guide/export-interactive-forms.php
''' </remarks>
Shared Sub Main(ByVal args() As String)
' Before starting this example, please get a free 100-day trial key:
' https://sautinsoft.com/start-for-free/
' Apply the key here:
' PdfDocument.SetLicense("...");
Dim pdfFile As String = Path.GetFullPath("..\..\..\FormFilled.pdf")
Using document = PdfDocument.Load(pdfFile)
'Export form data as fdf stream.
Dim fdfFile = New FileStream("fdfOut.fdf", FileMode.Create)
document.Form.ExportData(fdfFile, SautinSoft.Pdf.Forms.PdfFormDataFormat.FDF)
'Export form data to xfdf file.
document.Form.ExportData("xfdfOut.xfdf")
'Export form data to json file.
document.Form.ExportData("jsonOut.json")
End Using
End Sub
End Class
End Namespace
Если вам нужен пример кода или у вас есть вопрос: напишите нам по адресу support@sautinsoft.ru или спросите в онлайн-чате (правый нижний угол этой страницы) или используйте форму ниже: