com.sun.pdfview

Class PDFTextFormat

public class PDFTextFormat extends Object implements Cloneable

a class encapsulating the text state
Constructor Summary
PDFTextFormat()
create a new PDFTextFormat, with initial values
Method Summary
voidcarriageReturn()
perform a carriage return
voidcarriageReturn(float x, float y)
perform a carriage return by translating by x and y.
voiddoText(PDFPage cmds, String text)
add some text to the page.
voiddoText(PDFPage cmds, Object[] ary)
add some text to the page.
voidend()
end a span of text
voidflush()
finish any unfinished words.
floatgetCharSpacing()
get the char spacing
PDFFontgetFont()
get the font
floatgetFontSize()
get the font size
floatgetHorizontalScale()
Get the horizontal scale
floatgetLeading()
get the leading
intgetMode()
Get the mode of the text
floatgetRise()
Get the rise
AffineTransformgetTransform()
Get the current transform
floatgetWordSpacing()
get the word spacing
voidreset()
reset the PDFTextFormat for a new run
voidsetCharSpacing(float spc)
set the character spacing
voidsetFont(PDFFont f, float size)
set the font and size
voidsetHorizontalScale(float scl)
set the horizontal scale.
voidsetLeading(float spc)
set the leading
voidsetMatrix(float[] matrix)
set the transform matrix directly
voidsetMode(int m)
set the mode of the text.
voidsetRise(float spc)
set the rise
voidsetTextFormatMode(int mode)
Set the mode from another text format mode
voidsetWordSpacing(float spc)
set the word spacing

Constructor Detail

PDFTextFormat

public PDFTextFormat()
create a new PDFTextFormat, with initial values

Method Detail

carriageReturn

public void carriageReturn()
perform a carriage return

carriageReturn

public void carriageReturn(float x, float y)
perform a carriage return by translating by x and y. The next carriage return will be relative to the new location.

doText

public void doText(PDFPage cmds, String text)
add some text to the page.

Parameters: cmds the PDFPage to add the commands to text the text to add

doText

public void doText(PDFPage cmds, Object[] ary)
add some text to the page.

Parameters: cmds the PDFPage to add the commands to ary an array of Strings and Doubles, where the Strings represent text to be added, and the Doubles represent kerning amounts.

end

public void end()
end a span of text

flush

public void flush()
finish any unfinished words. TODO: write this!

getCharSpacing

public float getCharSpacing()
get the char spacing

getFont

public PDFFont getFont()
get the font

getFontSize

public float getFontSize()
get the font size

getHorizontalScale

public float getHorizontalScale()
Get the horizontal scale

Returns: the horizontal scale, in percent

getLeading

public float getLeading()
get the leading

getMode

public int getMode()
Get the mode of the text

getRise

public float getRise()
Get the rise

getTransform

public AffineTransform getTransform()
Get the current transform

getWordSpacing

public float getWordSpacing()
get the word spacing

reset

public void reset()
reset the PDFTextFormat for a new run

setCharSpacing

public void setCharSpacing(float spc)
set the character spacing

setFont

public void setFont(PDFFont f, float size)
set the font and size

setHorizontalScale

public void setHorizontalScale(float scl)
set the horizontal scale.

Parameters: scl the horizontal scale, in percent (100=normal)

setLeading

public void setLeading(float spc)
set the leading

setMatrix

public void setMatrix(float[] matrix)
set the transform matrix directly

setMode

public void setMode(int m)
set the mode of the text. The correspondence of m to mode is show in the following table. m is a value from 0-7 in binary: 000 Fill 001 Stroke 010 Fill + Stroke 011 Nothing 100 Fill + Clip 101 Stroke + Clip 110 Fill + Stroke + Clip 111 Clip Therefore: Fill corresponds to the low bit being 0; Clip corresponds to the hight bit being 1; and Stroke corresponds to the middle xor low bit being 1.

setRise

public void setRise(float spc)
set the rise

setTextFormatMode

public void setTextFormatMode(int mode)
Set the mode from another text format mode

Parameters: mode the text render mode using the codes from PDFShapeCmd and not the wacky PDF codes

setWordSpacing

public void setWordSpacing(float spc)
set the word spacing