Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.faceless.pdf2
Class PDFStyle

    java.lang.Object
      org.faceless.pdf2.PDFStyle

All Implemented Interfaces:
  Cloneable

    public class PDFStyle

extends Object
implements Cloneable

A PDFStyle controls the colors, font and many other aspects of the actual display of elements on a PDF page. It's conceptually similar to a CSS style used with HTML markup.

The idea behind the PDFStyle class is that you create a style and then apply it to the `PDFPage`. This means you can switch from one style to another with a single command, and switch back just as easily. It makes defining a consistant "feel" to your document much easier than it would if you had to set the font and color separately.

Example

       import java.awt.Color;

       // Create a new style "normal": 12pt black Times-Roman, with
       // line-spacing of 1.5
       PDFStyle normal = new PDFStyle();
       normal.setFont(new StandardFont(StandardFont.TIMES), 12);
       normal.setFillColor(Color.black);
       normal.setTextLineSpacing(1.5);

       // Create a new varient of "normal": 12pt red Times-Italic with
       // the same line-spacing
       PDFStyle italic = new PDFStyle(normal);
       italic.setFont(new StandardFont(StandardFont.TIMESITALIC), 12);
       italic.setFillColor(Color.red);

       // Create a style to draw a box around the text in green, with a
       // line width of 2 points
       PDFStyle boxstyle = new PDFStyle();
       boxstyle.setLineColor(Color.green);
       boxstyle.setLineWeighting(2);

       // Now use these styles in a document
       PDF p = new PDF();
       PDFPage page = p.newPage(PDF.PAGESIZE_A4);
       page.setStyle(normal);
       page.drawText("This is in 12pt black Times Roman", 100, 100);
       page.setStyle(italic);
       page.drawText("This is in 12pt red Times Italic", 100, 120);

       // Draw a box around them in green
       page.setStyle(boxstyle);
       page.drawRectangle(90,90, 200, 40);

This shows several useful aspects of styles:

- Styles can easily be extended by using the `PDFStyle(PDFStyle)` constructor
- Not all the aspects of a style need to be set
- Styles can be given meaningful names

Since:
  1.0

Field Summary
`static int` | `FONTSTYLE_FILLED` Set any text rendered in this style to be filled with the styles FillColor (the default)
`static int` | `FONTSTYLE_FILLEDOUTLINE` Set any text rendered in this style to be filled with the styles FillColor, then to be outlined with the styles' LineColor
`static int` | `FONTSTYLE_INVISIBLE` Set any text rendered in this style to be invisible.
`static int` | `FONTSTYLE_OUTLINE` Set any text rendered in this style to be drawn as a hollow outline with the styles LineColor (the default)
`static char` | `FORMRADIOBUTTONSTYLE_CHECK` A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a check mark (a tick) when selected.
`static char` | `FORMRADIOBUTTONSTYLE_CIRCLE` A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a filled circle when selected.
`static char` | `FORMRADIOBUTTONSTYLE_CROSS` A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a cross or "X" when selected.
`static char` | `FORMRADIOBUTTONSTYLE_DIAMOND` A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a filled diamond when selected.
`static char` | `FORMRADIOBUTTONSTYLE_SQUARE` A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a filled square when selected.
`static char` | `FORMRADIOBUTTONSTYLE_STAR` A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a filled five-pointed star when selected.
`static int` | `FORMSTYLE_BEVEL` Style for `setFormStyle(int)` which draws an border around the field so that it looks beveled.
`static int` | `FORMSTYLE_CLOUDY1` Style for `setFormStyle(int)` which causes the border to be "cloudy" with small curves This style only applies to some `AnnotationShape` classes and `AnnotationText`
`static int` | `FORMSTYLE_CLOUDY2` Style for `setFormStyle(int)` which causes the border to be "cloudy" with big curves.
`static int` | `FORMSTYLE_INSET` Style for `setFormStyle(int)` which draws an border around the field so that it looks inset into the page.
`static int` | `FORMSTYLE_INVERT` Style for `setFormStyle(int)` which causes the form element to be inverted when clicked
`static int` | `FORMSTYLE_OUTLINE` Style for `setFormStyle(int)` which causes the form element to be outlined when clicked
`static int` | `FORMSTYLE_SOLID` Style for `setFormStyle(int)` which draws a solid border around the field (the default)
`static int` | `FORMSTYLE_UNDERLINE` Style for `setFormStyle(int)` which draws a single line under the field
`static int` | `LINECAP_BUTT` Set the end of a line to be squared off at the end.
`static int` | `LINECAP_ROUND` Set the end of a line to be rounded at the end.
`static int` | `LINECAP_SQUARE` Set the end of a line to be squared at the end.
`static int` | `LINEJOIN_BEVEL` Sets the join style of two lines so that the lines are beveled.
`static int` | `LINEJOIN_MITER` Sets the join style of two lines so that the lines are extended so they meet at a point (like a picture frame).
`static int` | `LINEJOIN_ROUND` Sets the join style of two lines so that the lines are rounded, equivalent to drawing a circle with a diameter of the linewidth where the lines meet.
`static PDFStyle` | `LINKSTYLE` This style is a predefined convenience style - it can be passed into `PDFPage.beginTextLink(org.faceless.pdf2.PDFAction, org.faceless.pdf2.PDFStyle)` to underline the text in the link.
`static int` | `PAINTMETHOD_EVENODD` A parameter to `setPaintMethod(int)` to set the paint method to use the even-odd method to determine which areas are inside or outside a shape.
`static int` | `PAINTMETHOD_NONZEROWINDING` A parameter to `setPaintMethod(int)` to set the paint method to use the non-zero winding number method to determine which areas are inside or outside a shape.
`static int` | `TEXTALIGN_BASELINE` Set the vertical text alignment for this style to baseline (the default).
`static int` | `TEXTALIGN_BOTTOM` Set the vertical text alignment for this style to bottom
`static int` | `TEXTALIGN_CENTER` Set the text alignment for this style to centered
`static int` | `TEXTALIGN_JUSTIFY` Set the text alignment for this style to justified (the default).
`static int` | `TEXTALIGN_JUSTIFY_ALL` Similar to `TEXTALIGN_JUSTIFY`, but will also justify the last line of a paragraph.
`static int` | `TEXTALIGN_LEFT` Set the text alignment for this style to left-aligned
`static int` | `TEXTALIGN_MIDDLE` Set the vertical text alignment for this style to middle
`static int` | `TEXTALIGN_RIGHT` Set the text alignment for this style to right-aligned
`static int` | `TEXTALIGN_TOP` Set the vertical text alignment for this style to top

Constructor Summary
`PDFStyle()` Create a new PDFStyle using the default settings.
`PDFStyle(PDFStyle style)` Create a new style which is a clone of the specified style

Method Summary
`void` | `addBackupFont(PDFFont font)` Add a backup font to the current style.
`Object` | `clone()` Create a duplicate of this font.
`PDFGlyphVector` | `createGlyphVector(String text, Locale locale)` Returns a PDFGlyphVector containing the glyph codes for the specified text in this style.
`boolean` | `equals(Object o)`
`PDFFont` | `getBackupFont(int i)` Get the specified backup font, as set by `addBackupFont(org.faceless.pdf2.PDFFont)`.
`Paint` | `getFillColor()` Return the fill color, as set by `setFillColor(java.awt.Paint)`
`PDFFont` | `getFont()` Return the font, as set by `setFont(org.faceless.pdf2.PDFFont, float)`
`float` | `getFontLeading()` Return the text leading for this styles in points.
`float` | `getFontSize()` Return the font size of this style, as set by `setFont(org.faceless.pdf2.PDFFont, float)`
`int` | `getFontStyle()` Return the font style as set by `setFontStyle(int)`
`char` | `getFormCheckboxStyle()` Returns the checkbox style of the current style, as set by `setFormCheckboxStyle(char)`.
`int` | `getFormFieldOrientation()` Return the form field orientation, as set by `setFormFieldOrientation(int)`.
`char` | `getFormRadioButtonStyle()` Returns the radiobutton style of the current style, as set by `setFormRadioButtonStyle(char)`.
`int` | `getFormStyle()` Returns the form-style of the current style, as set by `setFormStyle(int)`.
`int` | `getLineCap()` Return the line cap, as set by `setLineCap(int)`
`Paint` | `getLineColor()` Return the line color, as set by `setLineColor(java.awt.Paint)`
`float` | `getLineDashOff()` Deprecated. since 2.7.8 this method has been replaced with `getLineDashPattern()`
`float` | `getLineDashOn()` Deprecated. since 2.7.8 this method has been replaced with `getLineDashPattern()`
`float[]` | `getLineDashPattern()` Return the line dash pattern, as set by `setLineDash(float, float, float)`.
`float` | `getLineDashPhase()` Get the "phase" part of the line dash pattern, as set by `setLineDash(float, float, float)`
`int` | `getLineJoin()` Return the line join, as set by `setLineJoin(int)`
`float` | `getLineWeighting()` Return the line weighting, as set by `setLineWeighting(float)`
`int` | `getTextAlign()` Return the text alignment.
`float` | `getTextBottom(String s)` Get the bottom-most Y co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size.
`float` | `getTextIndent()` Return the text indent value as set by `setTextIndent(float)`
`float` | `getTextLeft(String s)` Get the left-most X co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size.
`float` | `getTextLength(char[] c, int off, int len)` Get the length of the specified string in points, using the styles font and font size.
`float` | `getTextLength(String s)` Get the length of the specified string in points, using the styles font and font size.
`float` | `getTextLineSpacing()` Return the text line spacing, as set by `setTextLineSpacing(float)`
`float` | `getTextRight(String s)` Get the right-most X co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size.
`float` | `getTextTop(String s)` Get the top-most Y co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size.
`float` | `getTextWidths(char[] buf, int off, int len, float[] widths, float[] kerns)` As `getTextLength()` but sets the width of each character in the specified arrays; a very low level routine unlikely to be used by many, but useful for calculating break points for advanced layout engines like the Report Generator.
`int` | `hashCode()`
`void` | `setBlendMode(String mode)` Set the "Blend Mode" of this style.
`void` | `setFillColor(Paint paint)` Set the fill color.
`void` | `setFont(PDFFont font, float size)` Set the font and font size for this style.
`void` | `setFontStyle(int style)` Set the font render style.
`void` | `setFormCheckboxStyle(char style)` For `FormCheckbox` elements, set the type of shape to use to show the checkbox is selected.
`void` | `setFormFieldOrientation(int rotate)` Set the angle of rotation for form fields created with this style as a background style.
`void` | `setFormRadioButtonStyle(char style)` For `FormRadioButton` elements, set the type of shape to use to show the button is selected.
`void` | `setFormStyle(int style)` Sets the style of a form fields background to one of `FORMSTYLE_SOLID`, `FORMSTYLE_INSET`,`FORMSTYLE_BEVEL`, `FORMSTYLE_INVERT`, `FORMSTYLE_OUTLINE` or `FORMSTYLE_UNDERLINE`.
`void` | `setLineCap(int cap)` Set the line cap style.
`void` | `setLineColor(Paint paint)` Set the line color.
`void` | `setLineDash(float[] pattern, float phase)` Set the line dashing pattern.
`void` | `setLineDash(float on, float off, float phase)` Set the line dashing pattern.
`void` | `setLineJoin(int join)` Set the line join style.
`void` | `setLineWeighting(float weight)` Set the line weighting, for fonts and geometric shapes drawn as outlines.
`void` | `setOverprint(boolean on)` Cause text and objects drawn with this style to overprint.
`void` | `setPaintMethod(int method)` Set the paint method to either `PAINTMETHOD_EVENODD` or `PAINTMETHOD_NONZEROWINDING` (the default).
`void` | `setStrokeAdjustment(boolean sa)` Set whether this style uses Stroke Adjustment
`void` | `setTextAlign(int textalign)` Set the text alignment for this style.
`void` | `setTextDoubleUnderline(boolean on)` Set whether text rendered with this style is double-underlined or not.
`void` | `setTextIndent(float indent)` Set the number of points to indent the first line of any text drawn in this style.
`void` | `setTextJustificationRatio(float i)` Set the text justification ratio for a style.
`void` | `setTextLineSpacing(float spacing)` Set the spacing between lines of text.
`void` | `setTextRise(float offset)` Set the text vertical offset - the distance between the standard baseline and the basline for this style, as a proportion of the font size.
`void` | `setTextSmallCaps(boolean on)` Set whether text in this style is displayed with "small-caps" - ie. all lower case letters are displayed as upper-case but at 80% of the original font-size.
`void` | `setTextStretch(float stretch)` Set how much text is stretched horizontally.
`void` | `setTextStrikeOut(boolean on)` Set whether text rendered with this style is struck-out or not.
`void` | `setTextUnderline(boolean on)` Set whether text rendered with this style is underlined or not.
`void` | `setTrackKerning(float kern)` Allows you to explicitly set the kerning between characters for a font.
`PDFStyle` | `subscriptClone()` Return a new style which is the "subscripted" version of the current style.
`PDFStyle` | `superscriptClone()` Return a new style which is the "superscripted" version of the current style.
`String` | `toString()`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### LINKSTYLE

    public static final PDFStyle LINKSTYLE

  This style is a predefined convenience style - it can be passed into `PDFPage.beginTextLink(org.faceless.pdf2.PDFAction, org.faceless.pdf2.PDFStyle)` to underline the text in the link.

### TEXTALIGN_LEFT

    public static final int TEXTALIGN_LEFT

  Set the text alignment for this style to left-aligned

  See Also:
    Constant Field Values

### TEXTALIGN_RIGHT

    public static final int TEXTALIGN_RIGHT

  Set the text alignment for this style to right-aligned

  See Also:
    Constant Field Values

### TEXTALIGN_CENTER

    public static final int TEXTALIGN_CENTER

  Set the text alignment for this style to centered

  See Also:
    Constant Field Values

### TEXTALIGN_JUSTIFY

    public static final int TEXTALIGN_JUSTIFY

  Set the text alignment for this style to justified (the default). Justification is only useful when text is written within a paragraph. When a single element of text is drawn, the effect is the same as left-alignment.

  See Also:
    Constant Field Values

### TEXTALIGN_JUSTIFY_ALL

    public static final int TEXTALIGN_JUSTIFY_ALL

  Similar to `TEXTALIGN_JUSTIFY`, but will also justify the last line of a paragraph.

  Since:
    2.2.1
  See Also:
    Constant Field Values

### TEXTALIGN_BASELINE

    public static final int TEXTALIGN_BASELINE

  Set the vertical text alignment for this style to baseline (the default).

  See Also:
    Constant Field Values

### TEXTALIGN_TOP

    public static final int TEXTALIGN_TOP

  Set the vertical text alignment for this style to top

  See Also:
    Constant Field Values

### TEXTALIGN_MIDDLE

    public static final int TEXTALIGN_MIDDLE

  Set the vertical text alignment for this style to middle

  See Also:
    Constant Field Values

### TEXTALIGN_BOTTOM

    public static final int TEXTALIGN_BOTTOM

  Set the vertical text alignment for this style to bottom

  See Also:
    Constant Field Values

### LINECAP_BUTT

    public static final int LINECAP_BUTT

  Set the end of a line to be squared off at the end. There is no projection beyond the end of the path. This is the default

  See Also:
    Constant Field Values

### LINECAP_ROUND

    public static final int LINECAP_ROUND

  Set the end of a line to be rounded at the end. Effectively draws a circle with a diameter of the line width at the end of each line.

  See Also:
    Constant Field Values

### LINECAP_SQUARE

    public static final int LINECAP_SQUARE

  Set the end of a line to be squared at the end. Effectively extends each line by half the linewidth.

  See Also:
    Constant Field Values

### LINEJOIN_MITER

    public static final int LINEJOIN_MITER

  Sets the join style of two lines so that the lines are extended so they meet at a point (like a picture frame). For extremely sharp angles, this will automatically be converted to a LINEJOIN_BEVEL. This is the default.

  See Also:
    Constant Field Values

### LINEJOIN_ROUND

    public static final int LINEJOIN_ROUND

  Sets the join style of two lines so that the lines are rounded, equivalent to drawing a circle with a diameter of the linewidth where the lines meet.

  See Also:
    Constant Field Values

### LINEJOIN_BEVEL

    public static final int LINEJOIN_BEVEL

  Sets the join style of two lines so that the lines are beveled. The two lines are drawn with LINECAP_BUTT ends, and the notch between the two segments is filled in with a triangle.

  See Also:
    Constant Field Values

### FONTSTYLE_FILLED

    public static final int FONTSTYLE_FILLED

  Set any text rendered in this style to be filled with the styles FillColor (the default)

  See Also:
    Constant Field Values

### FONTSTYLE_OUTLINE

    public static final int FONTSTYLE_OUTLINE

  Set any text rendered in this style to be drawn as a hollow outline with the styles LineColor (the default)

  See Also:
    Constant Field Values

### FONTSTYLE_FILLEDOUTLINE

    public static final int FONTSTYLE_FILLEDOUTLINE

  Set any text rendered in this style to be filled with the styles FillColor, then to be outlined with the styles' LineColor

  See Also:
    Constant Field Values

### FONTSTYLE_INVISIBLE

    public static final int FONTSTYLE_INVISIBLE

  Set any text rendered in this style to be invisible. This becomes useful in applications like OCR, where the original scanned image is displayed on the screen and invisible text written above it, allowing the text to be cut and pasted.

  See Also:
    Constant Field Values

### PAINTMETHOD_NONZEROWINDING

    public static final int PAINTMETHOD_NONZEROWINDING

  A parameter to `setPaintMethod(int)` to set the paint method to use the non-zero winding number method to determine which areas are inside or outside a shape. This is the default.

  See Also:
    Constant Field Values

### PAINTMETHOD_EVENODD

    public static final int PAINTMETHOD_EVENODD

  A parameter to `setPaintMethod(int)` to set the paint method to use the even-odd method to determine which areas are inside or outside a shape.

  See Also:
    Constant Field Values

### FORMSTYLE_SOLID

    public static final int FORMSTYLE_SOLID

  Style for `setFormStyle(int)` which draws a solid border around the field (the default)

  See Also:
    Constant Field Values

### FORMSTYLE_INSET

    public static final int FORMSTYLE_INSET

  Style for `setFormStyle(int)` which draws an border around the field so that it looks inset into the page.

  See Also:
    Constant Field Values

### FORMSTYLE_BEVEL

    public static final int FORMSTYLE_BEVEL

  Style for `setFormStyle(int)` which draws an border around the field so that it looks beveled.

  See Also:
    Constant Field Values

### FORMSTYLE_UNDERLINE

    public static final int FORMSTYLE_UNDERLINE

  Style for `setFormStyle(int)` which draws a single line under the field

  See Also:
    Constant Field Values

### FORMSTYLE_INVERT

    public static final int FORMSTYLE_INVERT

  Style for `setFormStyle(int)` which causes the form element to be inverted when clicked

  See Also:
    Constant Field Values

### FORMSTYLE_OUTLINE

    public static final int FORMSTYLE_OUTLINE

  Style for `setFormStyle(int)` which causes the form element to be outlined when clicked

  See Also:
    Constant Field Values

### FORMSTYLE_CLOUDY1

    public static final int FORMSTYLE_CLOUDY1

  Style for `setFormStyle(int)` which causes the border to be "cloudy" with small curves This style only applies to some `AnnotationShape` classes and `AnnotationText`

  Since:
    2.11.17
  See Also:
    Constant Field Values

### FORMSTYLE_CLOUDY2

    public static final int FORMSTYLE_CLOUDY2

  Style for `setFormStyle(int)` which causes the border to be "cloudy" with big curves. This style only applies to some `AnnotationShape` classes and `AnnotationText`

  Since:
    2.11.17
  See Also:
    Constant Field Values

### FORMRADIOBUTTONSTYLE_CHECK

    public static final char FORMRADIOBUTTONSTYLE_CHECK

  A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a check mark (a tick) when selected. This is the default for `FormCheckbox` elements.

  Since:
    2.0
  See Also:
    Constant Field Values

### FORMRADIOBUTTONSTYLE_CIRCLE

    public static final char FORMRADIOBUTTONSTYLE_CIRCLE

  A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a filled circle when selected. This is default for `FormRadioButton` elements.

  Since:
    2.0
  See Also:
    Constant Field Values

### FORMRADIOBUTTONSTYLE_CROSS

    public static final char FORMRADIOBUTTONSTYLE_CROSS

  A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a cross or "X" when selected.

  Since:
    2.0
  See Also:
    Constant Field Values

### FORMRADIOBUTTONSTYLE_SQUARE

    public static final char FORMRADIOBUTTONSTYLE_SQUARE

  A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a filled square when selected.

  Since:
    2.0
  See Also:
    Constant Field Values

### FORMRADIOBUTTONSTYLE_DIAMOND

    public static final char FORMRADIOBUTTONSTYLE_DIAMOND

  A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a filled diamond when selected.

  Since:
    2.0
  See Also:
    Constant Field Values

### FORMRADIOBUTTONSTYLE_STAR

    public static final char FORMRADIOBUTTONSTYLE_STAR

  A value for `setFormRadioButtonStyle(char)` and `setFormCheckboxStyle(char)` which sets the appearance for those elements to a filled five-pointed star when selected.

  Since:
    2.0
  See Also:
    Constant Field Values

Constructor Detail

### PDFStyle

    public PDFStyle()

  Create a new PDFStyle using the default settings. No fill color, line color or font is specified

### PDFStyle

    public PDFStyle(PDFStyle style)

  Create a new style which is a clone of the specified style

  Since:
    2.0

Method Detail

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### equals

    public boolean equals(Object o)

  Overrides:
    `equals` in class `Object`

### setFillColor

    public void setFillColor(Paint paint)

  Set the fill color. For text, this is the color of the text. For geometric shapes, this is paint to fill those shapes with. To draw only outlines, set it to `null` (the default).

  Prior to release 1.2, this method took a `Color` as an argument, but this has been changed to its superclass `Paint` instead. Although most of the time the parameter will still be a plain color, this change allows a `GradientPaint` to be used as well.

  Parameters:
    `paint` - the paint to use, or `null` if no fill is required.
  Since:
    1.0

### setLineColor

    public void setLineColor(Paint paint)

  Set the line color. For text, this is the color of the outline of the text. For geometric shapes, this is color to draw the outlines of those shapes. If no outline is required, set it to `null` (the default).

  Parameters:
    `paint` - the Color to use, or `null` if no outline is required.
  Since:
    1.0

### setLineWeighting

    public void setLineWeighting(float weight)

  Set the line weighting, for fonts and geometric shapes drawn as outlines. The minimum possible value is zero, which indicates to the PDF renderer to use the thinest line possible. On high-resolution devices this will become nearly invisible, and because of its device-dependent nature a value of 0 is not recommended.

  Changes to this setting midway through a `path` don't take effect until the path is closed.

  Parameters:
    `weight` - the thickness of the line in points, or 0 for "as thin as possible"
  Since:
    1.0

### setLineDash

    public void setLineDash(float on,
                            float off,
                            float phase)

  Set the line dashing pattern. Since 2.7.8 this method simply calls `setLineDash(new float[] { on, off }, phase)`.

  Parameters:
    `on` - how many points of the line to draw
    `off` - how many points of the line to skip
    `phase` - how far into the pattern to start
  Since:
    1.0

### setLineDash

    public void setLineDash(float[] pattern,
                            float phase)

  Set the line dashing pattern. The `pattern` parameter is an array of 1 or more float values that are > 0, which define the length in points of the alternating "on" and "off" segments of any lines drawn with this style. The `phase` paramter determines how far into this pattern to start.

  To draw solid lines, the first parameter should be `null`.

  Changes to this setting midway through a `path` don't take effect until the path is closed.

  Parameters:
    `pattern` - the pattern of alternating on/off segments, or `null` to draw solid lines
    `phase` - how far into the pattern to start
  Since:
    2.7.8

### setFont

    public void setFont(PDFFont font,
                        float size)

  Set the font and font size for this style. For styles passed in to `Form.setTextStyle(org.faceless.pdf2.PDFStyle)` and `WidgetAnnotation.setTextStyle(org.faceless.pdf2.PDFStyle)`, a font size of zero means "autosize" the text. In other situatios, a zero size will cause an error when the style is used to render text.

  Parameters:
    `font` - the font to use
    `size` - the size of the font. Must be greater than zero, except in the situation above when it may also be equal to zero.
  Since:
    1.0

### setTextAlign

    public void setTextAlign(int textalign)

  Set the text alignment for this style. The alignment may be any one of `TEXTALIGN_LEFT`, `TEXTALIGN_RIGHT`, `TEXTALIGN_CENTER` or `TEXTALIGN_JUSTIFY`), which control the horizontal alignment, added to any one of `TEXTALIGN_BASELINE`, `TEXTALIGN_TOP`, `TEXTALIGN_MIDDLE` or `TEXTALIGN_BOTTOM`, which control the vertical alignment.

  Parameters:
    `textalign` - the text alignment to use for this style
  Since:
    1.0, with vertical alignment added in 1.2

### setTextLineSpacing

    public void setTextLineSpacing(float spacing)

  Set the spacing between lines of text. The paramater is a multiple of the default spacing between lines for this font (as determined by the `PDFFont.getDefaultLeading()` method). This allows individual fonts to set their preferred line spacing more accurately.

  The default value is 1, for single-spaced text. A value of 1.5 sets line-and-a-half spacing, a value of 2 gives double spacing, and so on.

  Parameters:
    `spacing` - the spacing between lines
  Since:
    1.0

### setTextIndent

    public void setTextIndent(float indent)

  Set the number of points to indent the first line of any text drawn in this style. Positive values result in the first line being indented to the right, negative values in the first line being indented to the left (this is reversed for RTL scripts)

  Note that mixing styles with different text-indent levels on the first line of text in a paragraph will result in unpredictable results.

  Since:
    1.1.21

### setTextJustificationRatio

    public void setTextJustificationRatio(float i)

  Set the text justification ratio for a style. When a line of text is padded to justify it against two margins, there is always the the option of extending the space between each character, extending the space between each word, or a combination of the two. The "justification ratio" determines how much to apply to each. A ratio of 0 means "only extend the spaces between words", a ratio of 1 means "only extend the spaces between letters". The default is 0.5.

  Since:
    1.0

### setFontStyle

    public void setFontStyle(int style)

  Set the font render style. Can be one of `FONTSTYLE_FILLED` (the default), `FONTSTYLE_OUTLINE`, `FONTSTYLE_FILLEDOUTLINE` or `FONTSTYLE_INVISIBLE`.

  Since:
    1.1

### setOverprint

    public void setOverprint(boolean on)

  Cause text and objects drawn with this style to overprint. Has no effect unless the fill and/or line color are CMYK or Spot colors. The default is `false`.

  Since:
    2.10

### setTextUnderline

    public void setTextUnderline(boolean on)

  Set whether text rendered with this style is underlined or not. The exact position and width of the underlining is font specific. The default is false.

  Since:
    1.1

### setTextDoubleUnderline

    public void setTextDoubleUnderline(boolean on)

  Set whether text rendered with this style is double-underlined or not. The exact position and width of the underlining is font specific. The default is false.

  Since:
    2.11.12

### setTextStrikeOut

    public void setTextStrikeOut(boolean on)

  Set whether text rendered with this style is struck-out or not. The default is false.

  Since:
    1.1

### setTextSmallCaps

    public void setTextSmallCaps(boolean on)

  Set whether text in this style is displayed with "small-caps" - ie. all lower case letters are displayed as upper-case but at 80% of the original font-size. The default is false.

  Since:
    2.5

### setTrackKerning

    public void setTrackKerning(float kern)

  Allows you to explicitly set the kerning between characters for a font. This method may be called as many times as necessary - between each character if required - to set the kerning distance between characters for all future text rendered in this style ("characters" in this context includes spaces). This "track kerning" is used as well as the standard "pair-wise" kerning, as returned by `PDFFont.getKerning(char, char)`.

  If text-alignment is set to `TEXTALIGN_JUSTIFY`, kerning (both track and pairwise) is scaled up or down depending on the justification required.

  Parameters:
    `kern` - the space to place between each character in millipoints (thousandths of a point) if this font was rendered one point high. May be positive, which moves the characters apart, or negative to move them closer together.
  Since:
    1.1.14
  See Also:
    `PDFFont.getKerning(char, char)`

### setTextRise

    public void setTextRise(float offset)

  Set the text vertical offset - the distance between the standard baseline and the basline for this style, as a proportion of the font size. This is mainly used for superscripting or subscripting. text.

  As an example, if you wanted to create a line of text that was 6 points high and 6 points above the standard baseline, set the font size to 6 and the TextRise() to 1. (1x6 = 6 points above the baseline). To place the same text 3 points below the baseline, set the offset to -0.5.

  Since:
    1.1

### addBackupFont

    public void addBackupFont(PDFFont font)

  Add a backup font to the current style. Backup fonts are used when the standard font doesn't have a character defined - for example, creating a style with the "Times Roman" font and then adding a backup font of "Symbol" would allow text to be written in both English and Greek without changing styles. As many backup fonts as are required may be added.

  Parameters:
    `font` - the font to add as a backup for the current style.
  Since:
    1.2

### setFormStyle

    public void setFormStyle(int style)

  Sets the style of a form fields background to one of `FORMSTYLE_SOLID`, `FORMSTYLE_INSET`,`FORMSTYLE_BEVEL`, `FORMSTYLE_INVERT`, `FORMSTYLE_OUTLINE` or `FORMSTYLE_UNDERLINE`. This method can be applied to the background style passed into the `Form.setBackgroundStyle(org.faceless.pdf2.PDFStyle)` and `WidgetAnnotation.setBackgroundStyle(org.faceless.pdf2.PDFStyle)` methods, but for all other purposes (eg. setting the style of a page), this setting is ignored.

  Parameters:
    `style` - the type of background to draw the form field.
  Since:
    1.1.23

### setFormRadioButtonStyle

    public void setFormRadioButtonStyle(char style)

  For `FormRadioButton` elements, set the type of shape to use to show the button is selected. The default value is `FORMRADIOBUTTONSTYLE_CIRCLE`, which creates round radio buttons in the traditional HTML style

  Parameters:
    `style` - one of `FORMRADIOBUTTONSTYLE_CIRCLE`, `FORMRADIOBUTTONSTYLE_CHECK`, `FORMRADIOBUTTONSTYLE_DIAMOND`, `FORMRADIOBUTTONSTYLE_CROSS`, `FORMRADIOBUTTONSTYLE_SQUARE` or `FORMRADIOBUTTONSTYLE_STAR`
  Since:
    2.0

### setFormCheckboxStyle

    public void setFormCheckboxStyle(char style)

  For `FormCheckbox` elements, set the type of shape to use to show the checkbox is selected. The default value is `FORMRADIOBUTTONSTYLE_CHECK`, which creates checkboxes in the traditional HTML style

  Parameters:
    `style` - one of `FORMRADIOBUTTONSTYLE_CIRCLE`, `FORMRADIOBUTTONSTYLE_CHECK`, `FORMRADIOBUTTONSTYLE_DIAMOND`, `FORMRADIOBUTTONSTYLE_CROSS`, `FORMRADIOBUTTONSTYLE_SQUARE` or `FORMRADIOBUTTONSTYLE_STAR`
  Since:
    2.0

### setPaintMethod

    public void setPaintMethod(int method)

  Set the paint method to either `PAINTMETHOD_EVENODD` or `PAINTMETHOD_NONZEROWINDING` (the default). The paint method determines which area of a self-intersecting polygon is filled. If your polygons aren't self-intersecting, it has no effect.

  This setting is very obscure and is really only here for completeness. For a full discussion of the difference see the PDF Reference manual version 1.4, page 169.

  Since:
    1.1.5

### setLineCap

    public void setLineCap(int cap)

  Set the line cap style. Line caps are the shape of the end of the line - normally not noticable unless you're drawing very thick lines or are zoomed in a long way. The default is `LINECAP_BUTT`

  Changes to this setting midway through a `path` don't take effect until the path is closed.

  This setting is very obscure and is really only here for completeness. For a full discussion of the difference see the PDF Reference manual version 1.4, page 153.

  Parameters:
    `cap` - one of `LINECAP_BUTT`, `LINECAP_ROUND` or `LINECAP_SQUARE`
  Since:
    1.0

### setLineJoin

    public void setLineJoin(int join)

  Set the line join style. Line caps are the shape of the join between two line segments - normally not noticable unless you're drawing very thick lines or are zoomed in a long way. The default is `LINEJOIN_MITER`

  Changes to this setting midway through a `path` don't take effect until the path is closed.

  This setting is very obscure and is really only here for completeness. For a full discussion of the difference see the PDF Reference manual version 1.4, page 153.

  Parameters:
    `join` - one of `LINEJOIN_MITER`, `LINEJOIN_ROUND` or `LINEJOIN_BEVEL`.
  Since:
    1.0

### getLineCap

    public int getLineCap()

  Return the line cap, as set by `setLineCap(int)`

### getLineJoin

    public int getLineJoin()

  Return the line join, as set by `setLineJoin(int)`

### getLineColor

    public Paint getLineColor()

  Return the line color, as set by `setLineColor(java.awt.Paint)`

### getFillColor

    public Paint getFillColor()

  Return the fill color, as set by `setFillColor(java.awt.Paint)`

### getFontSize

    public float getFontSize()

  Return the font size of this style, as set by `setFont(org.faceless.pdf2.PDFFont, float)`

  Since:
    1.0

### getTextLineSpacing

    public float getTextLineSpacing()

  Return the text line spacing, as set by `setTextLineSpacing(float)`

### getLineWeighting

    public float getLineWeighting()

  Return the line weighting, as set by `setLineWeighting(float)`

### getTextAlign

    public int getTextAlign()

  Return the text alignment. This method can be used to return the alignment of `FormText` Widget annotations. It can not be used to determine the alignment of text extracted from the body of the PDF - alignment is not a concept used by PDF except in form fields.

  Since:
    2.6.5

### getTextIndent

    public float getTextIndent()

  Return the text indent value as set by `setTextIndent(float)`

  Since:
    1.1.21

### getFontLeading

    public float getFontLeading()

  Return the text leading for this styles in points. The leading is the distance between the baseline of two successive lines of text, and is defined as:
  `getFontSize() * font.getDefaultLeading() * getLineSpacing()`

  Since:
    1.0

### getFontStyle

    public int getFontStyle()

  Return the font style as set by `setFontStyle(int)`

### setTextStretch

    public void setTextStretch(float stretch)

  Set how much text is stretched horizontally. By default the text has a horizontal stretch factor of 1.0, but this can be increased (to widen the text) or reduced to narrow it. The supplied value must be greater than zero.

  Parameters:
    `stretch` - the text stretch factor. Must be >0.
  Since:
    2.0.3

### getLineDashOn

    public float getLineDashOn()

  Deprecated. since 2.7.8 this method has been replaced with `getLineDashPattern()`

  Get the "on" part of the line dash pattern, as set by `setLineDash(float, float, float)`

  Since:
    2.0

### getLineDashOff

    public float getLineDashOff()

  Deprecated. since 2.7.8 this method has been replaced with `getLineDashPattern()`

  Get the "off" part of the line dash pattern, as set by `setLineDash(float, float, float)`

  Since:
    2.0

### getLineDashPhase

    public float getLineDashPhase()

  Get the "phase" part of the line dash pattern, as set by `setLineDash(float, float, float)`

  Since:
    1.1

### getLineDashPattern

    public float[] getLineDashPattern()

  Return the line dash pattern, as set by `setLineDash(float, float, float)`. The returned value is `null` if no dash pattern is in use, or an array of 1 or more positive values.

  Since:
    2.7.8

### getFont

    public PDFFont getFont()

  Return the font, as set by `setFont(org.faceless.pdf2.PDFFont, float)`

  Since:
    1.0

### getBackupFont

    public PDFFont getBackupFont(int i)

  Get the specified backup font, as set by `addBackupFont(org.faceless.pdf2.PDFFont)`. The argument to this method determines which backup font to return - zero for the first, one for the second and so on.

  Parameters:
    `i` - the backup font to return
  Returns:
    the specified backup font, or `null` if no backup font exists at that index.
  Since:
    1.2

### getFormStyle

    public int getFormStyle()

  Returns the form-style of the current style, as set by `setFormStyle(int)`.

  Since:
    1.1.23

### getFormRadioButtonStyle

    public char getFormRadioButtonStyle()

  Returns the radiobutton style of the current style, as set by `setFormRadioButtonStyle(char)`.

  Since:
    2.0

### getFormCheckboxStyle

    public char getFormCheckboxStyle()

  Returns the checkbox style of the current style, as set by `setFormCheckboxStyle(char)`.

  Since:
    2.0

### getFormFieldOrientation

    public int getFormFieldOrientation()

  Return the form field orientation, as set by `setFormFieldOrientation(int)`. Returned value will be one of 0, 90, 180 or 270.

  Since:
    2.7.7

### setStrokeAdjustment

    public void setStrokeAdjustment(boolean sa)

  Set whether this style uses Stroke Adjustment

### setFormFieldOrientation

    public void setFormFieldOrientation(int rotate)

  Set the angle of rotation for form fields created with this style as a background style.

  Parameters:
    `rotate` - the form rotation - one of 0 (the default), 90, 180 or 270.
  Since:
    2.7.7

### getTextLength

    public float getTextLength(String s)

  Get the length of the specified string in points, using the styles font and font size. The line of text must not contain any newlines. For horizontal fonts, this is equivalent to `getTextRight()-getTextLeft()`. This method takes track-kerning into account.

  Parameters:
    `s` - the String to measure the length of
  Returns:
    the length of the string in points if drawn in this style

### getTextLeft

    public float getTextLeft(String s)

  Get the left-most X co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size. The line of text must not contain any newlines. This method takes track-kerning into account.

  Returns:
    the left edge of the string in points if drawn in this style

### getTextRight

    public float getTextRight(String s)

  Get the right-most X co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size. The line of text must not contain any newlines. This method takes track-kerning into account.

  Returns:
    the right edge of the string in points if drawn in this style

### getTextTop

    public float getTextTop(String s)

  Get the top-most Y co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size. The line of text must not contain any newlines.

  Returns:
    the top edge of the string in points if drawn in this style

### getTextBottom

    public float getTextBottom(String s)

  Get the bottom-most Y co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size. The line of text must not contain any newlines.

  Returns:
    the bottom edge of the string in points if drawn in this style

### getTextWidths

    public float getTextWidths(char[] buf,
                               int off,
                               int len,
                               float[] widths,
                               float[] kerns)

  As `getTextLength()` but sets the width of each character in the specified arrays; a very low level routine unlikely to be used by many, but useful for calculating break points for advanced layout engines like the Report Generator.

  Parameters:
    `buf` - the character buffer to use
    `off` - the offset into that buffer to start at
    `len` - the number of characters to process
    `widths` - if not null, an array `len` long which will be populated with the width of each character in points
    `kerns` - If not null, an array `len` long which will be populated with the kerning values after each character, in points. Negative values move the next character closer, positive moves them further away.
  Returns:
    the total width of the text, as from `getTextLength()`
  Since:
    2.6

### getTextLength

    public float getTextLength(char[] c,
                               int off,
                               int len)

  Get the length of the specified string in points, using the styles font and font size. As for `getTextLength(String)` but takes a char array, and the text must be `ligaturized` first if necessary.

  Parameters:
    `c` - the character buffer to use
    `off` - the offset into that buffer to start at
    `len` - the number of characters to process
  Since:
    1.2.1

### clone

    public Object clone()

  Create a duplicate of this font. It's probably more convenient to use the `PDFStyle(PDFStyle)` constructor, as it will save you having to typecast the response

  Overrides:
    `clone` in class `Object`

### superscriptClone

    public PDFStyle superscriptClone()

  Return a new style which is the "superscripted" version of the current style.

  Since:
    1.1

### subscriptClone

    public PDFStyle subscriptClone()

  Return a new style which is the "subscripted" version of the current style.

  Since:
    1.1

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### setBlendMode

    public void setBlendMode(String mode)

  Set the "Blend Mode" of this style. The mode may be one of "Normal", "Multiply", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", "ColorBurn", "HardLight", "SoftLight", "Difference" or "Exclusion". Blend modes may not work in all situations.

  Since:
    2.11.7

### createGlyphVector

    public PDFGlyphVector createGlyphVector(String text,
                                            Locale locale)
                                     throws CharConversionException

  Returns a PDFGlyphVector containing the glyph codes for the specified text in this style. This can then be drawn directly to a PDFCanvas. See the `PDFGlyphVector` class for an example.

  Parameters:
    `text` - the text to display
    `locale` - the locale of the text, or null to use the default
  Throws:
    `CharConversionException`
  Since:
    2.11.22
  See Also:
    `PDFGlyphVector`, `PDFCanvas.drawGlyphVector(org.faceless.pdf2.PDFGlyphVector, float, float)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2012 Big Faceless Organization