Class PdfLoadedForm
Represents Loaded form of the PDF document.
Inherited Members
Namespace: Syncfusion.Pdf.Parsing
Assembly: Syncfusion.Pdf.NET.dll
Syntax
public class PdfLoadedForm : PdfForm, IPdfWrapper
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)
Declaration
public bool EnableXfaFormFill { get; set; }
Property Value
Type |
---|
System.Boolean |
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)
Declaration
public bool ExportEmptyFields { get; set; }
Property Value
Type |
---|
System.Boolean |
Fields
Gets the field collection.[Read-Only]
Declaration
public PdfLoadedFormFieldCollection Fields { get; }
Property Value
Type |
---|
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.
Declaration
public override bool ReadOnly { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the field is read-only, false otherwise. Default is false. |
Overrides
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.
Declaration
public void ExportData(Stream stream, DataFormat dataFormat, string formName)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
DataFormat | dataFormat | The format of exported data |
System.String | formName | The name of the PDF file the data is exported from |
Remarks
The formName is only applicable when exporting data in FDF and XFDF formats.
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)
ExportData(Stream, ExportFormSettings)
Export the form data to a stream with specified ExportFormSettings.
Declaration
public void ExportData(Stream stream, ExportFormSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
ExportFormSettings | settings |
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)
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.Declaration
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)
HighlightFields(Boolean)
Sets or resets the form field highlight option.
Declaration
public void HighlightFields(bool highlight)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | highlight |
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)
ImportData(Stream, ImportFormSettings)
Imports the form data from the stream with the specified ImportFormSettings.
Declaration
public void ImportData(Stream stream, ImportFormSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
ImportFormSettings | settings |
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)
ImportDataFDF(Byte[])
Import form data from FDF file.
Declaration
public void ImportDataFDF(byte[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | array | 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)
ImportDataFDF(Stream)
Import form data from FDF file.
Declaration
public void ImportDataFDF(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.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)
ImportDataFDF(Stream, Boolean)
Import form data from FDF file.
Declaration
public PdfLoadedFieldImportError[] ImportDataFDF(Stream stream, bool continueImportOnError)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The FDF file stream |
System.Boolean | continueImportOnError | 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
Type | Description |
---|---|
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)
ImportDataJson(Byte[])
Import form data from Json file.
Declaration
public void ImportDataJson(byte[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | array | 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)
ImportDataJson(Stream)
Import form data from Json file.
Declaration
public void ImportDataJson(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.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)
ImportDataXFDF(Byte[])
Declaration
public void ImportDataXFDF(byte[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | array |
ImportDataXFDF(Stream)
Declaration
public void ImportDataXFDF(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream |
ImportDataXML(Byte[])
Declaration
public void ImportDataXML(byte[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | array |
ImportDataXML(Stream)
Declaration
public void ImportDataXML(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream |
ImportDataXML(Stream, Boolean)
Declaration
public PdfLoadedFieldImportError[] ImportDataXML(Stream stream, bool continueImportOnError)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
System.Boolean | continueImportOnError |
Returns
Type |
---|
PdfLoadedFieldImportError[] |
OnlyHexInString(String)
Called when [hex in string].
Declaration
public bool OnlyHexInString(string test)
Parameters
Type | Name | Description |
---|---|---|
System.String | test | The test string. |
Returns
Type |
---|
System.Boolean |
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)