Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.lowagie.text.pdf
Class PushbuttonField  view PushbuttonField download PushbuttonField.java

java.lang.Object
  extended bycom.lowagie.text.pdf.BaseField
      extended bycom.lowagie.text.pdf.PushbuttonField

public class PushbuttonField
extends BaseField

Creates a pushbutton field. It supports all the text and icon alignments. The icon may be an image or a template.

Example usage:

 Document document = new Document(PageSize.A4, 50, 50, 50, 50);
 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("output.pdf"));
 document.open();
 PdfContentByte cb = writer.getDirectContent();
 Image img = Image.getInstance("image.png");
 PushbuttonField bt = new PushbuttonField(writer, new Rectangle(100, 100, 200, 200), "Button1");
 bt.setText("My Caption");
 bt.setFontSize(0);
 bt.setImage(img);
 bt.setLayout(PushbuttonField.LAYOUT_ICON_TOP_LABEL_BOTTOM);
 bt.setBackgroundColor(Color.cyan);
 bt.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
 bt.setBorderColor(Color.red);
 bt.setBorderWidth(3);
 PdfFormField ff = bt.getButton();
 PdfAction ac = PdfAction.createSubmitForm("http://www.submit-site.com", null, 0);
 ff.setAction(ac);
 writer.addAnnotation(ff);
 document.close();
 


Field Summary
private  boolean iconFitToBounds
          Holds value of property iconFitToBounds.
private  float iconHorizontalAdjustment
          Holds value of property iconHorizontalAdjustment.
private  float iconVerticalAdjustment
          Holds value of property iconVerticalAdjustment.
private  com.lowagie.text.Image image
          Holds value of property image.
private  int layout
          Holds value of property layout.
static int LAYOUT_ICON_LEFT_LABEL_RIGHT
          A layout option
static int LAYOUT_ICON_ONLY
          A layout option
static int LAYOUT_ICON_TOP_LABEL_BOTTOM
          A layout option
static int LAYOUT_LABEL_LEFT_ICON_RIGHT
          A layout option
static int LAYOUT_LABEL_ONLY
          A layout option
static int LAYOUT_LABEL_OVER_ICON
          A layout option
static int LAYOUT_LABEL_TOP_ICON_BOTTOM
          A layout option
private  boolean proportionalIcon
          Holds value of property proportionalIcon.
static int SCALE_ICON_ALWAYS
          An icon scaling option
static int SCALE_ICON_IS_TOO_BIG
          An icon scaling option
static int SCALE_ICON_IS_TOO_SMALL
          An icon scaling option
static int SCALE_ICON_NEVER
          An icon scaling option
private  int scaleIcon
          Holds value of property scaleIcon.
private  PdfTemplate template
          Holds value of property template.
private  PdfTemplate tp
           
 
Fields inherited from class com.lowagie.text.pdf.BaseField
alignment, backgroundColor, BORDER_WIDTH_MEDIUM, BORDER_WIDTH_THICK, BORDER_WIDTH_THIN, borderColor, borderStyle, borderWidth, box, COMB, DO_NOT_SCROLL, DO_NOT_SPELL_CHECK, EDIT, fieldName, FILE_SELECTION, font, fontSize, HIDDEN, HIDDEN_BUT_PRINTABLE, maxCharacterLength, MULTILINE, options, PASSWORD, READ_ONLY, REQUIRED, rotation, text, textColor, visibility, VISIBLE, VISIBLE_BUT_DOES_NOT_PRINT, writer
 
Constructor Summary
PushbuttonField(PdfWriter writer, com.lowagie.text.Rectangle box, java.lang.String fieldName)
          Creates a new instance of PushbuttonField
 
Method Summary
private  float calculateFontSize(float w, float h)
           
protected  PdfAppearance getAppearance()
          Gets the button appearance.
 PdfFormField getField()
          Gets the pushbutton field.
 float getIconHorizontalAdjustment()
          Getter for property iconHorizontalAdjustment.
 float getIconVerticalAdjustment()
          Getter for property iconVerticalAdjustment.
 com.lowagie.text.Image getImage()
          Getter for property image.
 int getLayout()
          Getter for property layout.
 int getScaleIcon()
          Getter for property scaleIcon.
 PdfTemplate getTemplate()
          Getter for property template.
 boolean isIconFitToBounds()
          Getter for property iconFitToBounds.
 boolean isProportionalIcon()
          Getter for property proportionalIcon.
 void setIconFitToBounds(boolean iconFitToBounds)
          If true the icon will be scaled to fit fully within the bounds of the annotation, if false the border width will be taken into account.
 void setIconHorizontalAdjustment(float iconHorizontalAdjustment)
          A number between 0 and 1 indicating the fraction of leftover space to allocate at the left of the icon.
 void setIconVerticalAdjustment(float iconVerticalAdjustment)
          A number between 0 and 1 indicating the fraction of leftover space to allocate at the bottom of the icon.
 void setImage(com.lowagie.text.Image image)
          Sets the icon as an image.
 void setLayout(int layout)
          Sets the icon and label layout.
 void setProportionalIcon(boolean proportionalIcon)
          Sets the way the icon is scaled.
 void setScaleIcon(int scaleIcon)
          Sets the way the icon will be scaled.
 void setTemplate(PdfTemplate template)
          Sets the icon as a template.
 
Methods inherited from class com.lowagie.text.pdf.BaseField
breakLines, getAlignment, getBackgroundColor, getBorderAppearance, getBorderColor, getBorderStyle, getBorderWidth, getBox, getFieldName, getFont, getFontSize, getHardBreaks, getMaxCharacterLength, getOptions, getRealFont, getRotation, getText, getTextColor, getVisibility, getWriter, moveFields, setAlignment, setBackgroundColor, setBorderColor, setBorderStyle, setBorderWidth, setBox, setFieldName, setFont, setFontSize, setMaxCharacterLength, setOptions, setRotation, setRotationFromPage, setText, setTextColor, setVisibility, setWriter, trimRight
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAYOUT_LABEL_ONLY

public static final int LAYOUT_LABEL_ONLY
A layout option

See Also:
Constant Field Values

LAYOUT_ICON_ONLY

public static final int LAYOUT_ICON_ONLY
A layout option

See Also:
Constant Field Values

LAYOUT_ICON_TOP_LABEL_BOTTOM

public static final int LAYOUT_ICON_TOP_LABEL_BOTTOM
A layout option

See Also:
Constant Field Values

LAYOUT_LABEL_TOP_ICON_BOTTOM

public static final int LAYOUT_LABEL_TOP_ICON_BOTTOM
A layout option

See Also:
Constant Field Values

LAYOUT_ICON_LEFT_LABEL_RIGHT

public static final int LAYOUT_ICON_LEFT_LABEL_RIGHT
A layout option

See Also:
Constant Field Values

LAYOUT_LABEL_LEFT_ICON_RIGHT

public static final int LAYOUT_LABEL_LEFT_ICON_RIGHT
A layout option

See Also:
Constant Field Values

LAYOUT_LABEL_OVER_ICON

public static final int LAYOUT_LABEL_OVER_ICON
A layout option

See Also:
Constant Field Values

SCALE_ICON_ALWAYS

public static final int SCALE_ICON_ALWAYS
An icon scaling option

See Also:
Constant Field Values

SCALE_ICON_NEVER

public static final int SCALE_ICON_NEVER
An icon scaling option

See Also:
Constant Field Values

SCALE_ICON_IS_TOO_BIG

public static final int SCALE_ICON_IS_TOO_BIG
An icon scaling option

See Also:
Constant Field Values

SCALE_ICON_IS_TOO_SMALL

public static final int SCALE_ICON_IS_TOO_SMALL
An icon scaling option

See Also:
Constant Field Values

layout

private int layout
Holds value of property layout.


image

private com.lowagie.text.Image image
Holds value of property image.


template

private PdfTemplate template
Holds value of property template.


scaleIcon

private int scaleIcon
Holds value of property scaleIcon.


proportionalIcon

private boolean proportionalIcon
Holds value of property proportionalIcon.


iconVerticalAdjustment

private float iconVerticalAdjustment
Holds value of property iconVerticalAdjustment.


iconHorizontalAdjustment

private float iconHorizontalAdjustment
Holds value of property iconHorizontalAdjustment.


iconFitToBounds

private boolean iconFitToBounds
Holds value of property iconFitToBounds.


tp

private PdfTemplate tp
Constructor Detail

PushbuttonField

public PushbuttonField(PdfWriter writer,
                       com.lowagie.text.Rectangle box,
                       java.lang.String fieldName)
Creates a new instance of PushbuttonField

Method Detail

getLayout

public int getLayout()
Getter for property layout.


setLayout

public void setLayout(int layout)
Sets the icon and label layout. Possible values are LAYOUT_LABEL_ONLY, LAYOUT_ICON_ONLY, LAYOUT_ICON_TOP_LABEL_BOTTOM, LAYOUT_LABEL_TOP_ICON_BOTTOM, LAYOUT_ICON_LEFT_LABEL_RIGHT, LAYOUT_LABEL_LEFT_ICON_RIGHT and LAYOUT_LABEL_OVER_ICON. The default is LAYOUT_LABEL_ONLY.


getImage

public com.lowagie.text.Image getImage()
Getter for property image.


setImage

public void setImage(com.lowagie.text.Image image)
Sets the icon as an image.


getTemplate

public PdfTemplate getTemplate()
Getter for property template.


setTemplate

public void setTemplate(PdfTemplate template)
Sets the icon as a template.


getScaleIcon

public int getScaleIcon()
Getter for property scaleIcon.


setScaleIcon

public void setScaleIcon(int scaleIcon)
Sets the way the icon will be scaled. Possible values are SCALE_ICON_ALWAYS, SCALE_ICON_NEVER, SCALE_ICON_IS_TOO_BIG and SCALE_ICON_IS_TOO_SMALL. The default is SCALE_ICON_ALWAYS.


isProportionalIcon

public boolean isProportionalIcon()
Getter for property proportionalIcon.


setProportionalIcon

public void setProportionalIcon(boolean proportionalIcon)
Sets the way the icon is scaled. If true the icon is scaled proportionally, if false the scaling is done anamorphicaly.


getIconVerticalAdjustment

public float getIconVerticalAdjustment()
Getter for property iconVerticalAdjustment.


setIconVerticalAdjustment

public void setIconVerticalAdjustment(float iconVerticalAdjustment)
A number between 0 and 1 indicating the fraction of leftover space to allocate at the bottom of the icon. A value of 0 positions the icon at the bottom of the annotation rectangle. A value of 0.5 centers it within the rectangle. The default is 0.5.


getIconHorizontalAdjustment

public float getIconHorizontalAdjustment()
Getter for property iconHorizontalAdjustment.


setIconHorizontalAdjustment

public void setIconHorizontalAdjustment(float iconHorizontalAdjustment)
A number between 0 and 1 indicating the fraction of leftover space to allocate at the left of the icon. A value of 0 positions the icon at the left of the annotation rectangle. A value of 0.5 centers it within the rectangle. The default is 0.5.


calculateFontSize

private float calculateFontSize(float w,
                                float h)
                         throws java.io.IOException,
                                com.lowagie.text.DocumentException

getAppearance

protected PdfAppearance getAppearance()
                               throws java.io.IOException,
                                      com.lowagie.text.DocumentException
Gets the button appearance.


getField

public PdfFormField getField()
                      throws java.io.IOException,
                             com.lowagie.text.DocumentException
Gets the pushbutton field.


isIconFitToBounds

public boolean isIconFitToBounds()
Getter for property iconFitToBounds.


setIconFitToBounds

public void setIconFitToBounds(boolean iconFitToBounds)
If true the icon will be scaled to fit fully within the bounds of the annotation, if false the border width will be taken into account. The default is false.