Package com.sun.pdfview
Class PDFTextFormat
java.lang.Object
com.sun.pdfview.PDFTextFormat
- All Implemented Interfaces:
Cloneable
a class encapsulating the text state
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AffineTransformcurrent matrix transformprivate PDFFontfontprivate floatfont sizeprivate booleanare we between BT and ET?private AffineTransformmatrix transform at start of lineprivate Point2D.Floatlocation of the end of the previous hunk of textprivate floatcharacter spacingprivate floathorizontal scalingprivate floattext knockoutprivate floatleadingprivate inttext modeprivate floatrise amountprivate floatword spacingprivate StringBufferbuild text rep of wordprivate Point2D.Floatstart location of the hunk of text -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidperform a carriage returnvoidcarriageReturn(float x, float y) perform a carriage return by translating by x and y.clone()Clone the text formatvoidadd some text to the page.voidadd some text to the page.voidend()end a span of textvoidflush()finish any unfinished words.floatget the char spacinggetFont()get the fontfloatget the font sizefloatGet the horizontal scalefloatget the leadingintgetMode()Get the mode of the textfloatgetRise()Get the riseGet the current transformfloatget the word spacingvoidreset()reset the PDFTextFormat for a new runvoidsetCharSpacing(float spc) set the character spacingvoidset the font and sizevoidsetHorizontalScale(float scl) set the horizontal scale.voidsetLeading(float spc) set the leadingvoidsetMatrix(float[] matrix) set the transform matrix directlyvoidsetMode(int m) set the mode of the text.voidsetRise(float spc) set the risevoidsetTextFormatMode(int mode) Set the mode from another text format modevoidsetWordSpacing(float spc) set the word spacing
-
Field Details
-
tc
private float tccharacter spacing -
tw
private float twword spacing -
th
private float thhorizontal scaling -
tl
private float tlleading -
tr
private float trrise amount -
tm
private int tmtext mode -
tk
private float tktext knockout -
cur
current matrix transform -
line
matrix transform at start of line -
font
font -
fsize
private float fsizefont size -
inuse
private boolean inuseare we between BT and ET? -
word
build text rep of word -
wordStart
start location of the hunk of text -
prevEnd
location of the end of the previous hunk of text
-
-
Constructor Details
-
PDFTextFormat
public PDFTextFormat()create a new PDFTextFormat, with initial values
-
-
Method Details
-
reset
public void reset()reset the PDFTextFormat for a new run -
end
public void end()end a span of text -
getCharSpacing
public float getCharSpacing()get the char spacing -
setCharSpacing
public void setCharSpacing(float spc) set the character spacing -
getWordSpacing
public float getWordSpacing()get the word spacing -
setWordSpacing
public void setWordSpacing(float spc) set the word spacing -
getHorizontalScale
public float getHorizontalScale()Get the horizontal scale- Returns:
- the horizontal scale, in percent
-
setHorizontalScale
public void setHorizontalScale(float scl) set the horizontal scale.- Parameters:
scl- the horizontal scale, in percent (100=normal)
-
getLeading
public float getLeading()get the leading -
setLeading
public void setLeading(float spc) set the leading -
getFont
get the font -
getFontSize
public float getFontSize()get the font size -
setFont
set the font and size -
getMode
public int getMode()Get the mode of the text -
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. -
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
-
getRise
public float getRise()Get the rise -
setRise
public void setRise(float spc) set the rise -
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. -
getTransform
Get the current transform -
setMatrix
public void setMatrix(float[] matrix) set the transform matrix directly -
doText
add some text to the page.- Parameters:
cmds- the PDFPage to add the commands totext- the text to add
-
doText
add some text to the page.- Parameters:
cmds- the PDFPage to add the commands toary- an array of Strings and Doubles, where the Strings represent text to be added, and the Doubles represent kerning amounts.- Throws:
PDFParseException
-
flush
public void flush()finish any unfinished words. TODO: write this! -
clone
Clone the text format
-