Home  Products  Purchase  Downloads  Demos  Forums  Blogs  Ticket  Wiki  API  Corporate

com.aspose.pdf.kit
Class Form

java.lang.Object
  extended bycom.aspose.pdf.kit.Form

public class Form
extends java.lang.Object

Represents a class which is used to modify AcroForms Field in existing pdf documents. Various form fields can be easily modified or flattened with APIs, including: -text field -list box field -combo box field -radio button box field -check box field Additionally, image button field can be filled with a specified image. It can be used like this:

     //Open the document and create a Form object like this:
     Form form = new Form("Online.pdf", "output.pdf");
     //Add a logo field at the top of each page like this:
     form.setWaterMark("newwatermark.jpg");
     //Fill a text field like this:
     form.setField("fullName", "Luke Fu");
     //Select a  radio button like this:
     form.setField("gender", "male");
     //Paste a image onto the existing button field like this:
     form.fillImageField("photo", "watermark.jpg");
     //Choose a item from a combe box field like this:
     form.setField("bankList", "list Item3");
     //Choose a item from a list field like this:
     form.setField("period", "1 year");
     //Select a  ckeck box like this:
     form.setField("pay", "Yes");

     //Flatten all the fields like this:
     //form.allFlatten();

     //Close the document like this:
     form.close();
 


Constructor Summary
Form(java.io.InputStream srcStream, java.io.OutputStream dstStream)
          Represents a constructor of the Form object with source stream and destination stream.
Form(java.io.InputStream srcStream, java.lang.String desFilename)
          Represents a constructor of the Form object with source stream and destination file.
Form(java.lang.String srcFilename, java.io.OutputStream dstStream)
          Represents a constructor of the Form object with source file and destination stream.
Form(java.lang.String srcFilename, java.lang.String desFilename)
          Represents a constructor of the Form object with source file and destination file.
 
Method Summary
 void allFlatten()
          Flattens all fields in the specified pdf document.
 void close()
          Saves all the modifications and closes the destination file.
 void fillImageField(java.lang.String fieldName, java.lang.String imageFilename)
          Pastes an image onto the existing button field as its appearance.
 java.io.OutputStream getOutputStream()
          The getter of the mDestStream member.
 void partialFlatten(java.lang.String fieldName)
          Flattens part of the fields set in the specified pdf document.
 void setField(java.lang.String fieldName, java.lang.String value)
          Modifies the value of an existing field according to a specified field name.
 void setWaterMark(java.lang.String imageFilename)
          Inserts an appointed watermark or logo field at the top of the pdf document.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Form

public Form(java.lang.String srcFilename,
            java.lang.String desFilename)
     throws java.lang.Exception
Represents a constructor of the Form object with source file and destination file.

Parameters:
srcFilename - The path of the input pdf file.
desFilename - The path of the output pdf file.
Throws:
java.lang.Exception - On error.

Form

public Form(java.lang.String srcFilename,
            java.io.OutputStream dstStream)
     throws java.lang.Exception
Represents a constructor of the Form object with source file and destination stream.

Parameters:
srcFilename - The path of the input pdf file.
dstStream - The path of the output stream.
Throws:
java.lang.Exception - On error.

Form

public Form(java.io.InputStream srcStream,
            java.io.OutputStream dstStream)
     throws java.lang.Exception
Represents a constructor of the Form object with source stream and destination stream.

Parameters:
srcStream - The path of the input stream.
dstStream - The path of the output stream.
Throws:
java.lang.Exception - On error.

Form

public Form(java.io.InputStream srcStream,
            java.lang.String desFilename)
     throws java.lang.Exception
Represents a constructor of the Form object with source stream and destination file.

Parameters:
srcStream - The path of the input stream.
desFilename - The path of the pdf file.
Throws:
java.lang.Exception - On error.
Method Detail

setField

public void setField(java.lang.String fieldName,
                     java.lang.String value)
              throws java.lang.Exception
Modifies the value of an existing field according to a specified field name.

Parameters:
fieldName - The fully qualified field name.
value - The value to be appointed.
Throws:
java.lang.Exception

partialFlatten

public void partialFlatten(java.lang.String fieldName)
                    throws java.lang.Exception
Flattens part of the fields set in the specified pdf document.

Parameters:
fieldName - The fully qualified field name.
Throws:
java.lang.Exception - On flattening error.

allFlatten

public void allFlatten()
                throws java.lang.Exception
Flattens all fields in the specified pdf document.

Throws:
java.lang.Exception - On flattening error.

close

public void close()
           throws java.lang.Exception
Saves all the modifications and closes the destination file.

Throws:
java.lang.Exception - On closing error.

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.lang.Exception
The getter of the mDestStream member.

Throws:
java.lang.Exception

fillImageField

public void fillImageField(java.lang.String fieldName,
                           java.lang.String imageFilename)
                    throws PdfKitException,
                           java.io.IOException
Pastes an image onto the existing button field as its appearance.

Parameters:
fieldName - The fully qualified field name of the image button field.
imageFilename - The path of the image file, relative and absolute are both ok.
Throws:
PdfKitException
java.io.IOException

setWaterMark

public void setWaterMark(java.lang.String imageFilename)
                  throws java.net.MalformedURLException,
                         java.io.IOException,
                         com.aspose.pdf.kit.BadElementException,
                         PdfKitException
Inserts an appointed watermark or logo field at the top of the pdf document. These fields should be flattened manually.

Parameters:
imageFilename - The path of the watermark image or logo file, relative and absolute are both ok.
Throws:
java.net.MalformedURLException
java.io.IOException
com.aspose.pdf.kit.BadElementException
PdfKitException