![]() |
||
Home Products Purchase Downloads Demos Forums Blogs Ticket Wiki API Corporate |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.aspose.pdf.kit.FormEditor
Represents a class which is used to edit AcroForms Field in existing pdf documents. Users can add/delete all kinds of fields, and set their attributes and appearance as well.
//open the document and create a FormEditor object FormEditor formEditor = new FormEditor(path + "fieldAdd.pdf", path + "added.pdf"); //create a FormFieldFacade to specify visual attributes FormFieldFacade facade = new FormFieldFacade(); formEditor.setFacade(facade); //add a button field with grey background and beveled border facade.setBackgroudColor(new java.awt.Color(0xCC, 0xCC, 0xCC)); facade.setBorderStyle(FormFieldFacade.BDSTYLE_BEVELED); formEditor.addField(FormEditor.FLDTYP_BTNFLD, "button1", "OK", 1, new Rectangle(265, 695, 100, 25)); //add a text field with blue dashed border, green background, and red inverse text facade.setBorderColor(new java.awt.Color(0, 0, 255)); facade.setBorderStyle(FormFieldFacade.BDSTYLE_DASHED); facade.setBorderWidth(FormFieldFacade.BDWIDTH_THICK); facade.setBackgroudColor(new java.awt.Color(0, 255, 0)); facade.setAlignment(FormFieldFacade.ALIGN_CENTER); facade.setFont(FontStyle.TimesBoldItalic); facade.setTextColor(new java.awt.Color(255, 0, 0)); facade.setFontSize(12); facade.setRotation(180); formEditor.addField(FormEditor.FLDTYP_TXTFLD, "text1", "This is a line", 1, new Rectangle(215, 647, 200, 25)); //clear the settings formEditor.resetFacade(); //Close the document formEditor.close();
Field Summary | |
static int |
FLDTYP_BTNFLD
Defines a button field type. |
static int |
FLDTYP_CHKBOX
Defines a check box field type. |
static int |
FLDTYP_COMBOBOX
Defines a combo box field type. |
static int |
FLDTYP_LIST
Defines a list field type. |
static int |
FLDTYP_OTHERS
Defines unknown field type. |
static int |
FLDTYP_RADIOBTN
Defines a radio button field type. |
static int |
FLDTYP_TXTFLD
Defines a single text field type. |
Constructor Summary | |
FormEditor(java.io.InputStream srcStream,
java.io.OutputStream dstStream)
Represents a constructor of the FormEditor object with source stream and destination stream. |
|
FormEditor(java.io.InputStream srcStream,
java.lang.String desFilename)
Represents a constructor of the FormEditor object with source stream and destination file. |
|
FormEditor(java.lang.String srcFilename,
java.io.OutputStream dstStream)
Represents a constructor of the FormEditor object with source file and destination stream. |
|
FormEditor(java.lang.String srcFilename,
java.lang.String desFilename)
Represents a constructor of the FormEditor object with source file and destination file. |
Method Summary | |
void |
addField(int fieldType,
java.lang.String fieldName,
java.lang.String value,
int pageNum,
java.awt.Rectangle rect)
Insert a specified field into existing PDF document at corresponding position. |
void |
close()
Saves all the modifications and closes the destination file. |
void |
decorateField()
Change visual attributes of all fields. |
void |
decorateField(int fieldType)
Change visual attributes of all fields with the same field type. |
void |
decorateField(java.lang.String fieldName)
Change visual attributes of the specified field. |
void |
localCopyField(java.lang.String fieldName,
java.lang.String newFieldName,
int pageNum)
Copy an existing field from current page to another page in the same position. |
void |
localCopyField(java.lang.String fieldName,
java.lang.String newFieldName,
int pageNum,
float abscissa,
float ordinate)
Copies an existing field to a new position pecified by page number and ordinates. |
void |
moveTo(java.lang.String fieldName,
float right,
float up)
Moves the field to a new position specifying by relative offsets. |
void |
moveTo(java.lang.String fieldName,
float llx,
float lly,
float urx,
float ury)
Moves the field to a new position specifying by a couple of vertexs. |
void |
removeField(java.lang.String fieldName)
Remove a field specified by fieldName. |
void |
renameField(java.lang.String fieldName,
java.lang.String newFieldName)
Change a field's name. |
void |
resetFacade()
Reset all visual attributes to default values. |
void |
setFacade(FormFieldFacade facade)
Setter of member facade. |
void |
setFieldAttr(java.lang.String fieldName,
int flag)
|
void |
setFieldFlag(java.lang.String fieldName,
int flag)
Sets the field's appearance flags, including displayed, printed, zoomed, or rotated. |
void |
setItems(java.lang.String[] mItems)
Set items for combo box/list/radio box fields creation. |
void |
setRadioGap(float radioGap)
Setter of radioGap. |
void |
setRadioHoriz(boolean radioHoriz)
Setter of radioHoriz. |
void |
setSubmitBtnUrl(java.lang.String fieldName,
java.lang.String url)
Sets the url destination of a filed, only effective to submit buttons. |
void |
zoom(java.lang.String fieldName,
float scale)
Zooms the field proportionately according to the specific scale. |
void |
zoom(java.lang.String fieldName,
float scaleLength,
float scaleWidth)
Zooms the field according to the specific scales. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int FLDTYP_BTNFLD
public static final int FLDTYP_CHKBOX
public static final int FLDTYP_RADIOBTN
public static final int FLDTYP_TXTFLD
public static final int FLDTYP_LIST
public static final int FLDTYP_COMBOBOX
public static final int FLDTYP_OTHERS
Constructor Detail |
public FormEditor(java.lang.String srcFilename, java.lang.String desFilename) throws java.lang.Exception
srcFilename
- The path of the input pdf file.desFilename
- The path of the output pdf file.
java.lang.Exception
- On error.public FormEditor(java.lang.String srcFilename, java.io.OutputStream dstStream) throws java.lang.Exception
srcFilename
- The path of the input pdf file.dstStream
- The path of the output stream.
java.lang.Exception
- On error.public FormEditor(java.io.InputStream srcStream, java.io.OutputStream dstStream) throws java.lang.Exception
srcStream
- The path of the input stream.dstStream
- The path of the output stream.
java.lang.Exception
- On error.public FormEditor(java.io.InputStream srcStream, java.lang.String desFilename) throws java.lang.Exception
srcStream
- The path of the input stream.desFilename
- The path of the pdf file.
java.lang.Exception
- On error.Method Detail |
public void setItems(java.lang.String[] mItems)
mItems
- An array of string, each representing an
option of a combo box/list/radio box field.public void setRadioHoriz(boolean radioHoriz)
radioHoriz
- Specify the arranging style of radios,
true for horizontal and false for vertical.public void setRadioGap(float radioGap)
radioGap
- Specify the distance in pixel
between two neighbor radio buttons.public void resetFacade()
public void close() throws java.lang.Exception
java.lang.Exception
- On closing error.public void decorateField() throws java.lang.Exception
java.lang.Exception
- On errors.public void decorateField(int fieldType) throws java.lang.Exception
fieldType
- Field type of FormField.FLDTYP_*.
java.lang.Exception
- On errors.public void decorateField(java.lang.String fieldName) throws java.lang.Exception
fieldName
- The fully qualified field name.
java.lang.Exception
- On errers.public void setFieldAttr(java.lang.String fieldName, int flag) throws java.lang.Exception
java.lang.Exception
public void setFieldFlag(java.lang.String fieldName, int flag) throws java.lang.Exception
fieldName
- The fully qualified field name.flag
- The appearance flag to be set, must be Form.FLAG_*.
java.lang.Exception
- On error.public void moveTo(java.lang.String fieldName, float llx, float lly, float urx, float ury) throws java.lang.Exception
fieldName
- The fully qualified field name.llx
- The abscissa of the field's low left vertex.lly
- The ordinate of the field's low left vertex.urx
- The abscissa of the field's up right vertex.ury
- The ordinate of the field's up right vertex.
java.lang.Exception
- On error.public void moveTo(java.lang.String fieldName, float right, float up) throws java.lang.Exception
fieldName
- The fully qualified field name.right
- The relative offset of abscissa, positive referring to move right,
and negative referring to move left.up
- The relative offset of ordinate, positive referring to move up,
and negative referring to move down.
java.lang.Exception
- On error.public void zoom(java.lang.String fieldName, float scaleLength, float scaleWidth) throws java.lang.Exception
fieldName
- The fully qualified field name.scaleLength
- The scale for length zooming only, must be positive.scaleWidth
- The scale for width zooming only, must be positive.
java.lang.Exception
- On error.public void zoom(java.lang.String fieldName, float scale) throws java.lang.Exception
fieldName
- The fully qualified field name.scale
- The scale to zoom, both for the length and width.
java.lang.Exception
- On error.public void setSubmitBtnUrl(java.lang.String fieldName, java.lang.String url) throws java.lang.Exception
fieldName
- The fully qualified field name.url
- The destination to be assigned.
java.lang.Exception
- On error.public void addField(int fieldType, java.lang.String fieldName, java.lang.String value, int pageNum, java.awt.Rectangle rect) throws java.lang.Exception
fieldType
- The type of field adding, must be FormEditor.FLDTYP_*.fieldName
- The fully qualified field name.pageNum
- The page number that field will be inserted into.rect
- The Rectangle specifying a position to hold the new field.
java.lang.Exception
- On adding errors.public void removeField(java.lang.String fieldName)
fieldName
- The fully qualified field name.public void renameField(java.lang.String fieldName, java.lang.String newFieldName)
fieldName
- The old fully qualified field name.newFieldName
- The new fully qualified field name.public void localCopyField(java.lang.String fieldName, java.lang.String newFieldName, int pageNum) throws PdfKitException, java.lang.Exception
fieldName
- The old fully qualified field name.newFieldName
- The new fully qualified field name.
If null, it will be set as fieldName + "~".pageNum
- The number of page to hold the new field.
If zero, new field will be copid to the same page as old one hosted.
PdfKitException
- On errors.
java.lang.Exception
- On errors.public void localCopyField(java.lang.String fieldName, java.lang.String newFieldName, int pageNum, float abscissa, float ordinate) throws PdfKitException, java.lang.Exception
fieldName
- The old fully qualified field name.newFieldName
- The new fully qualified field name.
If null, it will be set as fieldName + "~".pageNum
- The number of page to hold the new field.
If zero, new field will be copid to the same page as old one hosted.abscissa
- The abscissa of the new field.ordinate
- The ordinate of the new field.
PdfKitException
- On errors.
java.lang.Exception
- On errors.public void setFacade(FormFieldFacade facade)
facade
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |