Table of Contents

Class PdfLoadedForm

Namespace
Syncfusion.Pdf.Parsing
Assembly
Syncfusion.Pdf.Portable.dll

Represents Loaded form of the PDF document.

public class PdfLoadedForm : PdfForm
Inheritance
PdfLoadedForm
Inherited Members

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm form = doc.Form;
//load the form field
PdfLoadedField field = form.Fields[0] as PdfLoadedField;
field.Export = true;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form
'load the form field
Dim field As PdfLoadedField = TryCast(form.Fields(0), PdfLoadedField)
field.Export = True
doc.Save("Form.pdf")
doc.Close(True)

Properties

EnableXfaFormFill

Enabling this property will fill both the AcroForm and XFA fields, and disabling this property will fill only AcroForm fields.

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm loadedForm = doc.Form;         
//Set EnableXfaForm  
loadedForm.EnableXfaFormFill = true;
PdfLoadedTextBoxField loadedTextBoxFieldDate = loadedForm.Fields[0] as PdfLoadedTextBoxField;
loadedTextBoxFieldDate.Text = "PDF";
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form
'Set the form as read only
form.EnableXfaFormFill = True
Dim ldField As PdfLoadedTextBoxField = TryCast(doc.Form.Fields(0), PdfLoadedTextBoxField)
ldField.Text = "PDF"
doc.Save("Form.pdf")
doc.Close(True)
public bool EnableXfaFormFill { get; set; }

Property Value

bool
See Also

ExportEmptyFields

Gets or sets the ExportEmptyFields property, enabling this will export the empty acroform fields.

//Load an existing document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf");
// Load an existing form
PdfLoadedForm loadedForm = loadedDocument.Form;
//Export empty fields
loadedForm.ExportEmptyFields = true;
//Export the existing PDF document to XML file
loadedForm.ExportData("Output.xml", DataFormat.Xml, @"AcroForm1");
//Close the document          
loadedDocument.Close(true);
'Load an existing document
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Load the existing form
 Dim loadedForm As PdfLoadedForm = loadedDocument.Form
'Export empty fields
loadedForm.ExportEmptyFields = True
'Export the existing PDF document to XML file
loadedForm.ExportData("Output.xml", DataFormat.Xml, "AcroForm1")       
loadedDocument.Close(True)
public bool ExportEmptyFields { get; set; }

Property Value

bool
See Also

Fields

Gets the field collection.[Read-Only]

public PdfLoadedFormFieldCollection Fields { get; }

Property Value

PdfLoadedFormFieldCollection

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm form = doc.Form;
//load the form field
PdfLoadedField field = form.Fields[0] as PdfLoadedField;
field.Export = true;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form
'load the form field
Dim field As PdfLoadedField = TryCast(form.Fields(0), PdfLoadedField)
field.Export = True
doc.Save("Form.pdf")
doc.Close(True)
See Also

ReadOnly

Gets or sets a value indicating whether the form is read only.

public override bool ReadOnly { get; set; }

Property Value

bool

True if the field is read-only, false otherwise. Default is false.

Examples

//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm form = doc.Form;         
//Set the form as read only
form.ReadOnly = true;
doc.Save("Form.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form
'Set the form as read only
form.ReadOnly = True
doc.Save("Form.pdf")
doc.Close(True)
See Also

Methods

ExportData(Stream, DataFormat, string)

Export the form data to a stream with the specific DataFormat and form name.

public void ExportData(Stream stream, DataFormat dataFormat, string formName)

Parameters

stream Stream
dataFormat DataFormat

The format of exported data

formName string

The name of the PDF file the data is exported from

Examples

 // Loads an existing document
 PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm form = doc.Form;
MemoryStream stream = new MemoryStream();
form.ExportData(stream, DataFormat.XFdf, "SourceForm.pdf");
doc.Close(true);
' Loads an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form
Dim stream As MemoryStream = New MemoryStream()
form.ExportData(stream, DataFormat.XFdf, "SourceForm.pdf")
doc.Close(True)

Remarks

The formName is only applicable when exporting data in FDF and XFDF formats.

See Also

ExportData(Stream, ExportFormSettings)

Export the form data to a stream with specified ExportFormSettings.

public void ExportData(Stream stream, ExportFormSettings settings)

Parameters

stream Stream
settings ExportFormSettings

Examples

// Load an existing document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Data/ChineseValue.pdf");
// Load an existing form
PdfLoadedForm loadedForm = loadedDocument.Form;
//Create new instance for export form settings.
ExportFormSettings settings = new ExportFormSettings();
//Gets or sets the data format to export form fields. 
settings.DataFormat = DataFormat.Fdf;
//Gets or sets the value that indicates the form name of the PDF form is export.
settings.FormName   = "formname";
MemoryStream stream = new MemoryStream();
//Export the form data to a stream with specified ExportFormSettings.
loadedForm.ExportData(stream, settings);
//Save the PDF document
loadedDocument.Save("ChineseValue.pdf");
//close the document
loadedDocument.Close(true);
'Load an existing document
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("../../Data/ChineseValue.pdf")
'Load an existing form
Dim loadedForm As PdfLoadedForm = loadedDocument.Form
'Create new instance for export form settings.
Dim settings As ExportFormSettings = New ExportFormSettings()
'Gets or sets the data format to export form fields. 
settings.DataFormat = DataFormat.Fdf
'Gets or sets the value that indicates the form name of the PDF form is export.
settings.FormName   = "formname"
'Export the existing PDF document to FDF file
Dim stream As MemoryStream = New MemoryStream()
'Export the form data to a stream with specified ExportFormSettings.
loadedForm.ExportData(stream, settings)
'Save the PDF document
loadedDocument.Save("ChineseValue.pdf")
'close the document
loadedDocument.Close(True)
See Also

FlattenFields()

PDF provides support to flatten a form field by removing the existing form field and replacing it with graphical objects that would resemble the form field and cannot be edited.

Flatten the form fields.
public void FlattenFields()

Examples

// Load an existing document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Data/input.pdf");
// Load an existing form
PdfLoadedForm loadedForm = loadedDocument.Form;
// Flatten the form fields.
loadedForm.FlattenFields();
//Save the PDF document
loadedDocument.Save("output.pdf");
//close the document
loadedDocument.Close(true);
'Load an existing document
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("../../Data/input.pdf")
'Load an existing form
Dim loadedForm As PdfLoadedForm = loadedDocument.Form
'Flatten the form fields.
loadedForm.FlattenFields()
'Save the PDF document
loadedDocument.Save("output.pdf")
'close the document
loadedDocument.Close(True)
See Also

HighlightFields(bool)

Sets or resets the form field highlight option.

public void HighlightFields(bool highlight)

Parameters

highlight bool

Examples

//Load an existing document.
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm form = doc.Form;
form.HighlightFields(true);
doc.Save("output.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form    
form.HighlightFields(True)
doc.Save("output.pdf")
doc.Close(True)
See Also

ImportData(Stream, ImportFormSettings)

Imports the form data from the stream with the specified ImportFormSettings.

public void ImportData(Stream stream, ImportFormSettings settings)

Parameters

stream Stream
settings ImportFormSettings

Examples

// Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
// Load an existing form
loadedForm = document.Form;
//Create new instance for import form settings.
ImportFormSettings settings = new ImportFormSettings();
// Gets or sets the data format to import form fields. 
settings.DataFormat = DataFormat.Fdf;
//Gets or sets the value that indicates the form name of the PDF form is import.
settings.FormName = "../../FDF_output.pdf";
FileStream stream = new FileStream("ImportFDF.fdf", FileMode.Open);
//Imports the form data from the stream with the specified ImportFormSettings.
loadedForm.ImportData(stream, settings);
//Save the PDF document
document.Save("WF_60299_Fdf.pdf");
//close the document
document.Close(true);
'Load an existing document
Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
'Load an existing form
loadedForm = document.Form
'Create new instance for import form settings.
Dim settings As ImportFormSettings = New ImportFormSettings()
'Gets or sets the data format to import form fields. 
settings.DataFormat = DataFormat.Fdf
'Gets or sets the value that indicates the form name of the PDF form is import.
settings.FormName = "../../FDF_output.pdf"
Dim stream As FileStream = New FileStream("ImportFDF.fdf", FileMode.Open)
'Imports the form data from the stream with the specified ImportFormSettings. 
loadedForm.ImportData(stream, settings)
//Save the PDF document
document.Save("WF_60299_Fdf.pdf")
//close the document
document.Close(True)
See Also

ImportDataFDF(byte[])

Import form data from FDF file.

public void ImportDataFDF(byte[] array)

Parameters

array byte[]

Array data of the fdf file.

Examples

//Load an existing document.
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm form = doc.Form;
// Load the FDF file
byte[] array = System.IO.File.ReadAllBytes("ImportFDF.fdf");
// Import the FDF stream
form.ImportDataFDF(array);
doc.Save("Import.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form
' Load the FDF file
Dim array As byte[] = System.IO.File.ReadAllBytes("ImportFDF.fdf")
' Import the FDF stream
form.ImportDataFDF(array)
doc.Save("Import.pdf")
doc.Close(True)
See Also

ImportDataFDF(Stream)

Import form data from FDF file.

public void ImportDataFDF(Stream stream)

Parameters

stream Stream

The FDF file stream

Examples

//Load an existing document.
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm form = doc.Form;
// Load the FDF file
FileStream stream = new FileStream("ImportFDF.fdf", FileMode.Open);
// Import the FDF stream
form.ImportDataFDF(stream);
doc.Save("Import.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form
' Load the FDF file
Dim stream As FileStream = New FileStream("ImportFDF.fdf", FileMode.Open)
' Import the FDF stream
form.ImportDataFDF(stream)
doc.Save("Import.pdf")
doc.Close(True)
See Also

ImportDataFDF(Stream, bool)

Import form data from FDF file.

public PdfLoadedFieldImportError[] ImportDataFDF(Stream stream, bool continueImportOnError)

Parameters

stream Stream

The FDF file stream

continueImportOnError bool

False if the import should stop on the first field that generates an error, or true if the import should ignore the error and continue with the next field.

Returns

PdfLoadedFieldImportError[]

Error messages wile importing.

Examples

//Load an existing document.
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm form = doc.Form;
// Load the FDF file
FileStream stream = new FileStream("ImportFDF.fdf", FileMode.Open);
// Import the FDF stream
form.ImportDataFDF(stream,true);
doc.Save("Import.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form
' Load the FDF file
Dim stream As FileStream = New FileStream("ImportFDF.fdf", FileMode.Open)
' Import the FDF stream
form.ImportDataFDF(stream,True)
doc.Save("Import.pdf")
doc.Close(True)
See Also

ImportDataJson(byte[])

Import form data from Json file.

public void ImportDataJson(byte[] array)

Parameters

array byte[]

Array data of Json file

Examples

//Load an existing document.
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm form = doc.Form;
 byte[] array = System.IO.File.ReadAllBytes(ImportJSON.json);
// Import the JSON file
form.ImportDataJson(array);
doc.Save("Import.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form
Dim array as byte[]=System.IO.File.ReadAllBytes(ImportJSON.json)
' Import the JSON file
form.ImportDataJson(array)
doc.Save("Import.pdf")
doc.Close(True)
See Also

ImportDataJson(Stream)

Import form data from Json file.

public void ImportDataJson(Stream stream)

Parameters

stream Stream

The Json file stream

Examples

//Load an existing document.
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm form = doc.Form;
// Load the Json file 
FileStream stream = new FileStream("ImportJSON.json", FileMode.Open);
// Import the JSON file stream
form.ImportDataJson(stream);
doc.Save("Import.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form
// Load the Json file 
Dim stream As FileStream= new FileStream("ImportJSON.json", FileMode.Open)
' Import the JSON file stream
form.ImportDataJson(stream)
doc.Save("Import.pdf")
doc.Close(True)
See Also

ImportDataXFDF(byte[])

public void ImportDataXFDF(byte[] array)

Parameters

array byte[]
See Also

ImportDataXFDF(Stream)

public void ImportDataXFDF(Stream stream)

Parameters

stream Stream
See Also

ImportDataXML(byte[])

public void ImportDataXML(byte[] array)

Parameters

array byte[]
See Also

ImportDataXML(Stream)

public void ImportDataXML(Stream stream)

Parameters

stream Stream
See Also

ImportDataXML(Stream, bool)

public PdfLoadedFieldImportError[] ImportDataXML(Stream stream, bool continueImportOnError)

Parameters

stream Stream
continueImportOnError bool

Returns

PdfLoadedFieldImportError[]
See Also

OnlyHexInString(string)

Called when [hex in string].

public bool OnlyHexInString(string test)

Parameters

test string

The test string.

Returns

bool

Examples

//Load an existing document.
PdfLoadedDocument doc = new PdfLoadedDocument("SourceForm.pdf");
// Load the existing form
PdfLoadedForm form = doc.Form;
bool isHex = form.OnlyHexInString("123456");
doc.Save("output.pdf");
doc.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceForm.pdf")
' Load the existing form
Dim form As PdfLoadedForm = doc.Form    
Dim isHex As Boolean = form.OnlyHexInString("123456")
doc.Save("output.pdf")
doc.Close(True)
See Also

See Also