Form

Inheritance: java.lang.Object, com.aspose.pdf.facades.IVentureLicenseTarget, com.aspose.pdf.facades.Facade, com.aspose.pdf.facades.SaveableFacade, com.aspose.pdf.facades.AForm

public final class Form extends AForm

Class representing Acro form object.

Constructors

ConstructorDescription
Form()Construtcor of Form without parameters.
Form(IDocument document)Initializes new Form object on base of the document .
Form(IDocument document, OutputStream destStream)Initializes new Form object on base of the document .
Form(IDocument document, String destFileName)Initializes new Form object on base of the document .
Form(InputStream srcStream)Constructor for form.
Form(InputStream srcStream, OutputStream destStream)Constructor of Form with two stream parameters.
Form(InputStream srcStream, String destFileName)Constructor of Form
Form(String srcFileName)Constructor of Form.
Form(String srcFileName, OutputStream destStream)Constructor of Form.
Form(String srcFileName, String destFileName)Constructor of Form class.

Methods

MethodDescription
bindPdf(InputStream srcStream, String password)Initializes the facade.
bindPdf(String srcFile, String password)Initializes the facade.
close()Closes opened files without any changes.
dispose()Closes all opened resources.
exportFdf(OutputStream outputFdfStream)Exports the content of the fields of the pdf into the fdf stream.
exportXfdf(OutputStream outputXfdfStream)Exports the content of the fields of the pdf into the xml stream.
exportXml(OutputStream outputXmlStream)Exports the content of the fields of the pdf into the xml stream.
extractXfaData(OutputStream outputXmlStream)Extracts XFA data packet
fillBarcodeField(String fieldName, String data)Fill a barcode field according to its fully qualified field name.
fillField(String fieldName, boolean beChecked)Fills the check box field with a boolean value.
fillField(String fieldName, int index)Fills the radio box field with a valid index value according to a fully qualified field name.
fillField(String fieldName, String fieldValue)Fills the field with a valid value according to a fully qualified field name.
fillField(String fieldName, String value, boolean fitFontSize)Fills field with specified value.
fillField(String fieldName, String[] fieldValues)Fill a field with multiple selections.Note: only for AcroForm List Box Field.
fillImageField(String fieldName, InputStream imageStream)Overloads function of FillImageField.
fillImageField(String fieldName, String imageFileName)Pastes an image onto the existing button field as its appearance according to its fully qualified field name.
flattenAllFields()Flattens all the fields.
flattenField(String fieldName)Flattens a specified field with the fully qualified field name.
getAttachmentName()Gets name of attachment when result of operation is stored into HttpResponse objects as attachment.
getButtonOptionCurrentValue(String fieldName)Returns the current value for radio button option fields.
getButtonOptionValues(String fieldName)Gets the radio button option fields and related values based on the field name.
getButtonOptionValuesInternal(String fieldName)Gets the radio button option fields and related values based on the field name.
getContentDisposition()Gets or sets how content will be stored when result of operation is stored into HttpResponse object.
getDestFileName()Gets destination file name.
getDestStream()Gets or sets destination stream.
getField(String fieldName)Gets the field’s value according to its field name.
getFieldFacade(String fieldName)Returns FormFieldFacade object containing all appearance attributes.
getFieldFlag(String fieldName)Returns flags of the field.
getFieldLimit(String fieldName)Get the limitation of text field.
getFieldNames()Gets list of field names on the form.
getFieldType(String fieldName)Returns type of field.
getFormSubmitButtonNames()Gets all form submit button names.
getFullFieldName(String fieldName)Gets the full field name according to its short field name.
getImportResult()Result of last import operation.
getRichText(String fieldName)Get a Rich Text field’s value, including the formatting information of every character.
getSaveOptions()Gets or sets save options when result is stored as HttpResponse.
getSrcFileName()Gets source file name.
getSrcStream()Gets source stream.
getSubmitFlags(String fieldName)Returns the submit button’s submission flags
importFdf(InputStream inputFdfStream)Imports the content of the fields from the fdf file and put them into the new pdf.
importXfdf(InputStream inputXfdfStream)Imports the content of the fields from the xfdf(xml) file and put them into the new pdf.
importXml(InputStream inputXmlStream)Imports the content of the fields from the xml file and put them into the new pdf.
importXml(InputStream inputXmlStream, boolean IgnoreFormTemplateChanges)Imports the content of the fields from the xml file and put them into the new pdf.
importXml(String inputXml)Imports the content of the fields from the xml file and put them into the new pdf.
isRequiredField(String fieldName)Determines whether field is required or not.
renameField(String fieldName, String newFieldName)Renames a field.
save()Saves the value of the filled fields and close the opened Pdf document.
save(OutputStream destStream)Saves document into specified stream.
save(String destFile)Saves document into specified file.
setAttachmentName(String value)Sets name of attachment when result of operation is stored into HttpResponse objects as attachment.
setContentDisposition(int value)Sets how content will be stored when result of operation is stored into HttpResponse object.
setConvertTo(PdfFormat value)Sets PDF file format.
setDestFileName(String value)Sets destination file name.
setDestStream(OutputStream value)Gets destination stream.
setSaveOptions(SaveOptions value)Gets or sets save options when result is stored as HttpResponse.
setSrcFileName(String value)Sets source file name.
setSrcStream(InputStream value)Gets source stream.
setXfaData(InputStream inputXmlStream)Replaces XFA data with specified data packet.

Form()

public Form()

Construtcor of Form without parameters.


Form form = new com.aspose.pdf.facades.Form();
   form.setSrcFileName( "file.pdf");

Form(IDocument document)

public Form(IDocument document)

Initializes new Form object on base of the document .

Parameters:

ParameterTypeDescription
documentIDocumentPdf document.

Form(IDocument document, OutputStream destStream)

public Form(IDocument document, OutputStream destStream)

Initializes new Form object on base of the document .

Parameters:

ParameterTypeDescription
documentIDocumentPdf document. Obsolete(“Use constructor without destination.”)
destStreamjava.io.OutputStreamDestination stream.

Form(IDocument document, String destFileName)

public Form(IDocument document, String destFileName)

Initializes new Form object on base of the document .

Obsolete(“Use constructor without destination.”)

Parameters:

ParameterTypeDescription
documentIDocumentPdf document.
destFileNamejava.lang.StringPath of the destination file.

Form(InputStream srcStream)

public Form(InputStream srcStream)

Constructor for form.


Form form = new Form(new FileInputStream("PdfForm.pdf");

Parameters:

ParameterTypeDescription
srcStreamjava.io.InputStreamsource stream.

Form(InputStream srcStream, OutputStream destStream)

public Form(InputStream srcStream, OutputStream destStream)

Constructor of Form with two stream parameters. Specify same source and destination stream for incremental update.


Form form = new Form(new FileInputStream("InFile.pdf"), new FileOutputStream("OutFile.pdf"));

Obsolete(“Use constructor without destination.”)

Parameters:

ParameterTypeDescription
srcStreamjava.io.InputStreamSource stream.
destStreamjava.io.OutputStreamDestination stream.

Form(InputStream srcStream, String destFileName)

public Form(InputStream srcStream, String destFileName)

Constructor of Form


Form form = new Form(new FileInputStream("PdfForm.pdf"), "PdfForm_Updated.pdf");

Parameters:

ParameterTypeDescription
srcStreamjava.io.InputStreamSource stream.
destFileNamejava.lang.StringDestination file path.

Form(String srcFileName)

public Form(String srcFileName)

Constructor of Form.


Form form = new Form("PdfForm.pdf");

Parameters:

ParameterTypeDescription
srcFileNamejava.lang.StringSource file path.

Form(String srcFileName, OutputStream destStream)

public Form(String srcFileName, OutputStream destStream)

Constructor of Form.


Form form = new Form("PdfForm.pdf", "PdfForm_Updated.pdf");
 Obsolete("Use constructor without destination.")

Parameters:

ParameterTypeDescription
srcFileNamejava.lang.StringSource file path.
destStreamjava.io.OutputStreamDestination file path.

Form(String srcFileName, String destFileName)

public Form(String srcFileName, String destFileName)

Constructor of Form class. Specify same source file name and destination file name to perform incremental update.


Form form = new Form("PdfForm.pdf", "PdfForm_Updated.pdf");

Parameters:

ParameterTypeDescription
srcFileNamejava.lang.StringPath of the source file.
destFileNamejava.lang.StringPath of the destination file.

bindPdf(InputStream srcStream, String password)

public void bindPdf(InputStream srcStream, String password)

Initializes the facade.

Parameters:

ParameterTypeDescription
srcStreamjava.io.InputStreamThe stream of PDF file.
passwordjava.lang.StringThe password of the PDF document.

bindPdf(String srcFile, String password)

public void bindPdf(String srcFile, String password)

Initializes the facade.

Parameters:

ParameterTypeDescription
srcFilejava.lang.StringThe PDF file.
passwordjava.lang.StringThe password of the PDF document.

close()

public void close()

Closes opened files without any changes.

dispose()

public void dispose()

Closes all opened resources.

This method is obsolete, use close() instead.

exportFdf(OutputStream outputFdfStream)

public void exportFdf(OutputStream outputFdfStream)

Exports the content of the fields of the pdf into the fdf stream.


Form form = new Form("PdfForm.pdf");
 OutputStream stream = new FileOutputStream("export.fdf");
 form.exportFdf(stream);
 stream.close();

Parameters:

ParameterTypeDescription
outputFdfStreamjava.io.OutputStreamThe output fdf stream.

exportXfdf(OutputStream outputXfdfStream)

public void exportXfdf(OutputStream outputXfdfStream)

Exports the content of the fields of the pdf into the xml stream. The button field’s value will not be exported.


Form form = new Form("PdfForm.pdf");
  FileInputStream fs = new FileInputStream("export.xfdf", FileMode.Create, FileAccess.Write);
  form.exportXfdf(fs);
  fs.close();

Parameters:

ParameterTypeDescription
outputXfdfStreamjava.io.OutputStreamThe output xml stream.

exportXml(OutputStream outputXmlStream)

public void exportXml(OutputStream outputXmlStream)

Exports the content of the fields of the pdf into the xml stream. The button field’s value will not be exported.


Form form = new Form("PdfForm.pdf"));
 OutputStream fs = new FileOutputStream("export.xml");
 form.exportXml(fs);
 fs.close();

Parameters:

ParameterTypeDescription
outputXmlStreamjava.io.OutputStreamOutput Xml stream.

extractXfaData(OutputStream outputXmlStream)

public void extractXfaData(OutputStream outputXmlStream)

Extracts XFA data packet

Parameters:

ParameterTypeDescription
outputXmlStreamjava.io.OutputStreamStream where XML data will be stored.

fillBarcodeField(String fieldName, String data)

public boolean fillBarcodeField(String fieldName, String data)

Fill a barcode field according to its fully qualified field name.


Form form = new Form("PdfForm.pdf");
 form.fillBarcodeField("textField", "42207252");

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe fully qualified field name.
datajava.lang.StringThe new barcode value.

Returns: boolean - If filling succeed, return true; otherwise, false.

fillField(String fieldName, boolean beChecked)

public boolean fillField(String fieldName, boolean beChecked)

Fills the check box field with a boolean value. Notice: Only be applied to Check Box. Please note that Facades supports only full field names and does not work with partial field names in contrast with Aspose.Pdf.Kit; For example if field has full name “Form.Subform.CheckBoxField” you should specify full name and not “CheckBoxField”. You can use FieldNames property to explore existing field names and search required field by its partial name.


Form form = new Form("PdfForm.pdf");
 form.fillField("checkboxField", true);


 //how to search field by its partial name:
 Form form = new Form("input.pdf", "output.pdf");
 for(String fieldName : form.getFieldNames())
 {
   if (fieldName.endsWith("CheckBoxField"))
   {
     System.out.println("Full name is: " + fieldName);
   }
 }

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe field’s name to be filled.
beCheckedbooleanA boolean flag: true means to check the box, while false to uncheck it.

Returns: boolean - true if field was found and successfully filled.

fillField(String fieldName, int index)

public boolean fillField(String fieldName, int index)

Fills the radio box field with a valid index value according to a fully qualified field name. Before filling the fields, only field’s name must be known. While the value can be specified by its index. Notice: Only be applied to Radio Box, Combo Box and List Box fields. Please note that Facades supports only full field names and does not work with partial field names in contrast with Aspose.Pdf.Kit; For example if field has full name “Form.Subform.ListBoxField” you should specify full name and not “ListBoxField”. You can use FieldNames property to explore existing field names and search required field by its partial name.


//1
 Form form = new Form("PdfForm.pdf");
 form.fillField("listboxField", 2);
 form.fillField("comboboxField", 2);
 form.fillField("radiobuttonField", 2);

 //2
 //how to search field by its partial name:
 Form form = new Form("input.pdf", "output.pdf");
 for(String fieldName : form.getFieldNames())
 {
   if (fieldName.endsWith("ListBoxField"))
   {
     System.out.println("Full name is: " + fieldName);
   }
 }

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of field to be filled.
indexintIndex of chosen item.

Returns: boolean - true if field was found and successfully filled.

fillField(String fieldName, String fieldValue)

public boolean fillField(String fieldName, String fieldValue)

Fills the field with a valid value according to a fully qualified field name. Before filling the fields, every field’s names and its corresponding valid values must be known. Both the fields’ name and values are case sensitive. Please note that Facades supports only full field names and does not work with partial field names in contrast with Aspose.Pdf.Kit; For example if field has full name “Form.Subform.TextField” you should specify full name and not “TextField”. You can use FieldNames property to explore existing field names and search required field by its partial name.


Form form = new Form("PdfForm.pdf");
 form.fillField("FirstName", "John");
 form.fillField("LastName",  "Smith");


 //how to search field by its partial name:
 Form form = new Form("input.pdf", "output.pdf");
 for(String fieldName : form.getFieldNames())
 {
   if (fieldName.endsWith("TextField"))
   {
     System.out.println("Full name is: " + fieldName);
   }
 }

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe field’s name to be filled.
fieldValuejava.lang.StringThe field’s value which must be a valid value for some fields.

Returns: boolean - true if field is found and filled successfully.

fillField(String fieldName, String value, boolean fitFontSize)

public boolean fillField(String fieldName, String value, boolean fitFontSize)

Fills field with specified value.

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of field
valuejava.lang.StringNew value of the field
fitFontSizebooleanIf true, the font size in the edit boxes will be fitted.

Returns: boolean - true if field was found and successfully filled.

fillField(String fieldName, String[] fieldValues)

public void fillField(String fieldName, String[] fieldValues)

Fill a field with multiple selections.Note: only for AcroForm List Box Field.


Form form = new com.aspose.pdf.Form("PdfForm.pdf", "Form_Updated.pdf");
 form.fillField("ListBox1", new String[] { "Three", "One" });
 form.save();

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe fully qualified field name.
fieldValuesjava.lang.String[]A String array which contains several items to be selected.

fillImageField(String fieldName, InputStream imageStream)

public void fillImageField(String fieldName, InputStream imageStream)

Overloads function of FillImageField. The input is a image stream.


Form form = new Form("PdfForm.pdf", "PdfForm_filled.pdf");
 form.fillImageField("fieldName", new FileInputStream("file.jpg", FileMode.Open, FileAccess.Read));

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe fully qualified field name.
imageStreamjava.io.InputStreamThe image’s stream.

fillImageField(String fieldName, String imageFileName)

public void fillImageField(String fieldName, String imageFileName)

Pastes an image onto the existing button field as its appearance according to its fully qualified field name.


Form form = new Form("PdfForm.pdf", "PdfForm_filled.pdf");
 form.fillImageField("fieldName", "file.jpg");
 form.save();

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe fully qualified field name of the image button field.
imageFileNamejava.lang.StringThe path of the image file, relative and absolute are both ok.

flattenAllFields()

public void flattenAllFields()

Flattens all the fields.


Form form = new Form("PdfForm.pdf");
 form.flattenAllFields();

flattenField(String fieldName)

public void flattenField(String fieldName)

Flattens a specified field with the fully qualified field name. Any other field will remain unchangeable. If the fieldName is invalid, all the fields will remain unchangeable.


Form form = new Form("PdfForm.pdf");
 form.flattenField("textField");

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe name of the field to be flattened.

getAttachmentName()

public String getAttachmentName()

Gets name of attachment when result of operation is stored into HttpResponse objects as attachment.

Returns: java.lang.String - string object

getButtonOptionCurrentValue(String fieldName)

public String getButtonOptionCurrentValue(String fieldName)

Returns the current value for radio button option fields.


Form form = new Form("PdfForm.pdf");
 System.out.println(form.GetButtonOptionCurrentValue("btnField"));

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringField Name

Returns: java.lang.String - String value for the current radio group option. See also GetButtonOptionValues

getButtonOptionValues(String fieldName)

public Hashtable<String,String> getButtonOptionValues(String fieldName)

Gets the radio button option fields and related values based on the field name. This method has meaning for radio button groups.


Form form = new Form("PdfForm.pdf");
 java.util.Map values = form.getButtonOptionValues("Color");
 System.out.println(values.get("White").toString());
 System.out.println(values.get("Black").toString());

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringField Name

Returns: java.util.Hashtable<java.lang.String,java.lang.String> - Hash table of option values keyed by form item name

getButtonOptionValuesInternal(String fieldName)

public System.Collections.Generic.Dictionary<String,String> getButtonOptionValuesInternal(String fieldName)

Gets the radio button option fields and related values based on the field name. This method has meaning for radio button groups.


Form form = new Form("PdfForm.pdf");
 Hashtable values = form.getButtonOptionValues("Color");
 System.out.println(values["White"].toString());
 System.out.println(values["Black"].toString());

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringField Name

Returns: Dictionary - Hash table of option values keyed by form item name

getContentDisposition()

public int getContentDisposition()

Gets or sets how content will be stored when result of operation is stored into HttpResponse object. Possible value: inline / attachment. Default: inline.

Returns: int - ContentDisposition element

getDestFileName()

public String getDestFileName()

Gets destination file name.

Returns: java.lang.String - string object

getDestStream()

public OutputStream getDestStream()

Gets or sets destination stream.

Returns: java.io.OutputStream - OutputStream object

getField(String fieldName)

public String getField(String fieldName)

Gets the field’s value according to its field name.


Form form = new Form("PdfForm.pdf");
 System.out.println("Field value = " + form.getField("Field1"));

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe fully qualified field name.

Returns: java.lang.String - The field’s value.

getFieldFacade(String fieldName)

public FormFieldFacade getFieldFacade(String fieldName)

Returns FormFieldFacade object containing all appearance attributes.


com.aspose.pdf.facades.Form form = new com.aspose.pdf.facades.Form("form.pdf"));
 FormFieldFacade field = form.getFieldFacade("field1");
 System.out.println("Color of field border: " + field.getBorderColor());

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringName of field to read.

Returns: FormFieldFacade - FormFieldFacade object

getFieldFlag(String fieldName)

public int getFieldFlag(String fieldName)

Returns flags of the field.


Form form = new Form("PdfForm.pdf");
 if (form.getFieldFlag("textField") == ProptyFlag.ReadOnly)
 {
    System.out.println("Field is read-only");
 }

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringField name

Returns: int - Property flag (ReadOnly/ Required/NoExport

getFieldLimit(String fieldName)

public int getFieldLimit(String fieldName)

Get the limitation of text field.


Form form = new Form("PdfForm.pdf");
 System.out.println(form.getFieldLimit("textfieldBox"));

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe qualified field name.

Returns: int - Return the limitation number of characters a text field can be filled. It not set, return 0.

getFieldNames()

public String[] getFieldNames()

Gets list of field names on the form.


Form form = new Form("PdfForm.pdf");
 String[] fields = form.getFieldNames();
 for(String field : fields)
 {
   System.out.println(field);
 }

Returns: java.lang.String[] - String[] object

getFieldType(String fieldName)

public FieldType getFieldType(String fieldName)

Returns type of field.


Form form = new Form("PdfForm.pdf");
 if (form.getFieldType("textField") == FieldType.Text)
 {
    System.out.println("Type of field is text");
 }

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringField name.

Returns: FieldType - Element of FileType enumeration corresponding to field type.

getFormSubmitButtonNames()

public String[] getFormSubmitButtonNames()

Gets all form submit button names.


Form form = new Form("PdfForm.pdf");
 String[] submits = form.getFormSubmitButtonNames();
 for(String btn : submits)
 {
   System.out.println(btn);
 }

Returns: java.lang.String[] - String[] object

getFullFieldName(String fieldName)

public String getFullFieldName(String fieldName)

Gets the full field name according to its short field name.


Form form = new Form("PdfForm.pdf");
 System.out.println("Full field name is : " + form.getFullFieldName("textField"));

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe fully qualified field name.

Returns: java.lang.String - The full field name.

getImportResult()

public AForm.FormImportResult[] getImportResult()

Result of last import operation. Array of objects which describe result of import for each field.

Returns: com.aspose.pdf.facades.AForm.FormImportResult[] - FormImportResult[] array

getRichText(String fieldName)

public String getRichText(String fieldName)

Get a Rich Text field’s value, including the formatting information of every character.


Form form = new Form("PdfForm.pdf");
 System.out.println(form.getRichText("txtDescriptionRTF"));

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe fully qualified field name of the Rich Text field.

Returns: java.lang.String - Return a String containing formatting information of the Rich Text field.

getSaveOptions()

public SaveOptions getSaveOptions()

Gets or sets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.

Returns: SaveOptions - SaveOptions object

getSrcFileName()

public String getSrcFileName()

Gets source file name.


Form form = new com.aspose.pdf.Form();
   form.setSrcFileName("file.pdf");

Returns: java.lang.String - string object

getSrcStream()

public InputStream getSrcStream()

Gets source stream.

Returns: java.io.InputStream - InputStream object

getSubmitFlags(String fieldName)

public SubmitFormFlag getSubmitFlags(String fieldName)

Returns the submit button’s submission flags


Form form = new Form("PdfForm.pdf");
 System.out.println( ( form.getSubmitFlags("btnSubmit") | SubmitFormFlag.Xfdf != 0) ? " XFDF" : " ");
 /// System.out.println( ( form.getSubmitFlags("btnSubmit") | SubmitFormFlag.Fdf != 0) ? " FDF" : " ");
 System.out.println( ( form.getSubmitFlags("btnSubmit") | SubmitFormFlag.Pdf != 0) ? " PDF" : " ");

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe qualified field name.

Returns: SubmitFormFlag - Submission flags of the button.

importFdf(InputStream inputFdfStream)

public void importFdf(InputStream inputFdfStream)

Imports the content of the fields from the fdf file and put them into the new pdf.


Form form = new Form("PdfForm.pdf", "PdfForm_imported.pdf");
 form.importFdf(new FileInputStream("data.fdf"));
 form.save();

Parameters:

ParameterTypeDescription
inputFdfStreamjava.io.InputStreamThe input fdf stream.

importXfdf(InputStream inputXfdfStream)

public void importXfdf(InputStream inputXfdfStream)

Imports the content of the fields from the xfdf(xml) file and put them into the new pdf.


Form form = new Form("PdfForm.pdf", "Form_ImportXfdf.pdf");
 InputStream fs = new FileInputStream("export_old.xfdf");
 form.importXfdf(fs);
 fs.close();
 form.save();

Parameters:

ParameterTypeDescription
inputXfdfStreamjava.io.InputStreamThe input xfdf(xml) stream.

importXml(InputStream inputXmlStream)

public void importXml(InputStream inputXmlStream)

Imports the content of the fields from the xml file and put them into the new pdf.


Form form = new Form("PdfForm.pdf");
 InputStream fs = new FileInputStream("import.xml");
 form.importXml(fs);
 form.save("Form_Imported.pdf");

Parameters:

ParameterTypeDescription
inputXmlStreamjava.io.InputStreamStream from which XML for import is read.

importXml(InputStream inputXmlStream, boolean IgnoreFormTemplateChanges)

public void importXml(InputStream inputXmlStream, boolean IgnoreFormTemplateChanges)

Imports the content of the fields from the xml file and put them into the new pdf.

Parameters:

ParameterTypeDescription
inputXmlStreamjava.io.InputStreamThe input xml stream.
IgnoreFormTemplateChangesbooleanIf this parameter is true then all changes of the XFA form template will not be saved

importXml(String inputXml)

public void importXml(String inputXml)

Imports the content of the fields from the xml file and put them into the new pdf.


Form form = new Form("PdfForm.pdf");
 form.importXml("import.xml");
 form.save( "Form_Imported.pdf");

Parameters:

ParameterTypeDescription
inputXmljava.lang.StringStream from which XML for import is read.

isRequiredField(String fieldName)

public boolean isRequiredField(String fieldName)

Determines whether field is required or not.

Parameters:

ParameterTypeDescription
fieldNamejava.lang.StringThe name of field.

Returns: boolean - True - the field is required; otherwise, false.

renameField(String fieldName, String newFieldName)

public void renameField(String fieldName, String newFieldName)

Renames a field. Either AcroForm field or XFA field is OK.


Form form = new Form("PdfForm.pdf", "PdfFormUpdated.pdf");
 form.renameField("field", "field1");
 form.save();

Parameters:

ParameterTypeDescription
fieldNamejava.lang.Stringthe old field name
newFieldNamejava.lang.Stringthe new field name

save()

public void save()

Saves the value of the filled fields and close the opened Pdf document.


Form form = new Form("PdfForm.pdf", "PdfForm_Changed.pdf");
 form.fillField("textField", "new value");
 form.save();

save(OutputStream destStream)

public void save(OutputStream destStream)

Saves document into specified stream.

Parameters:

ParameterTypeDescription
destStreamjava.io.OutputStreamStream where document will be saved.

save(String destFile)

public void save(String destFile)

Saves document into specified file.

Parameters:

ParameterTypeDescription
destFilejava.lang.StringFile where document will be saved.

setAttachmentName(String value)

public void setAttachmentName(String value)

Sets name of attachment when result of operation is stored into HttpResponse objects as attachment.

Parameters:

ParameterTypeDescription
valuejava.lang.String

setContentDisposition(int value)

public void setContentDisposition(int value)

Sets how content will be stored when result of operation is stored into HttpResponse object. Possible value: inline / attachment. Default: inline.

Parameters:

ParameterTypeDescription
valueintContentDisposition element

setConvertTo(PdfFormat value)

public void setConvertTo(PdfFormat value)

Sets PDF file format. Result file will be saved in specified file format. If this property is not specified then file will be save in default PDF format without conversion.

Parameters:

ParameterTypeDescription
valuePdfFormatPdfFormat element

setDestFileName(String value)

public void setDestFileName(String value)

Sets destination file name.


Form form = new com.aspose.pdf.Form();
   form.setDestFileName("file.pdf");

Parameters:

ParameterTypeDescription
valuejava.lang.StringString object

setDestStream(OutputStream value)

public void setDestStream(OutputStream value)

Gets destination stream.


Form form = new com.aspose.pdf.Form();
   form.setDestStream (new FileInputStream("file.pdf"));

Parameters:

ParameterTypeDescription
valuejava.io.OutputStreamOutputStream object

setSaveOptions(SaveOptions value)

public void setSaveOptions(SaveOptions value)

Gets or sets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.

Parameters:

ParameterTypeDescription
valueSaveOptionsSaveOptions object

setSrcFileName(String value)

public void setSrcFileName(String value)

Sets source file name.

Parameters:

ParameterTypeDescription
valuejava.lang.Stringstring object

setSrcStream(InputStream value)

public void setSrcStream(InputStream value)

Gets source stream.


Form form = new com.aspose.pdf.Form();
  form.setSrcStream (new FileInputStream("source.pdf")));

Parameters:

ParameterTypeDescription
valuejava.io.InputStreamInputStream object

setXfaData(InputStream inputXmlStream)

public void setXfaData(InputStream inputXmlStream)

Replaces XFA data with specified data packet. Data packet may be extracted using ExtractXfaData.

Parameters:

ParameterTypeDescription
inputXmlStreamjava.io.InputStreamStream where XML is stored.