Package org.loboevolution.pdfview
Class PDFTextFormat
java.lang.Object
org.loboevolution.pdfview.PDFTextFormat
- All Implemented Interfaces:
Cloneable
a class encapsulating the text state
Author Mike Wessler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
perform a carriage returnvoid
carriageReturn
(float x, float y) perform a carriage return by translating by x and y.clone()
void
add some text to the page.void
add some text to the page.void
end()
end a span of textvoid
flush()
finish any unfinished words.float
get the char spacingfloat
Get the horizontal scalefloat
get the leadingint
getMode()
Get the mode of the textfloat
getRise()
Get the risefloat
get the word spacingvoid
reset()
reset the PDFTextFormat for a new runvoid
setCharSpacing
(float spc) set the character spacingvoid
set the font and sizevoid
setHorizontalScale
(float scl) set the horizontal scale.void
setLeading
(float spc) set the leadingvoid
setMatrix
(float[] matrix) set the transform matrix directlyvoid
setMode
(int m) set the mode of the text.void
setRise
(float spc) set the risevoid
setTextFormatMode
(int mode) Set the mode from another text format modevoid
setWordSpacing
(float spc) set the word spacing
-
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- Returns:
- a float.
-
setCharSpacing
public void setCharSpacing(float spc) set the character spacing- Parameters:
spc
- a float.
-
getWordSpacing
public float getWordSpacing()get the word spacing- Returns:
- a float.
-
setWordSpacing
public void setWordSpacing(float spc) set the word spacing- Parameters:
spc
- a float.
-
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- Returns:
- a float.
-
setLeading
public void setLeading(float spc) set the leading- Parameters:
spc
- a float.
-
setFont
set the font and size- Parameters:
f
- aPDFFont
object.size
- a float.
-
getMode
public int getMode()Get the mode of the text- Returns:
- a
Integer
object.
-
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.- Parameters:
m
- aInteger
object.
-
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- Returns:
- a float.
-
setRise
public void setRise(float spc) set the rise- Parameters:
spc
- a float.
-
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.- Parameters:
x
- a float.y
- a float.
-
setMatrix
public void setMatrix(float[] matrix) set the transform matrix directly- Parameters:
matrix
- an array ofinvalid reference
float
-
doText
add some text to the page.- Parameters:
cmds
- the PDFPage to add the commands totext
- the text to addautoAdjustStroke
- a boolean.
-
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.autoAdjustStroke
- a boolean.- Throws:
PDFParseException
- if any.
-
flush
public void flush()finish any unfinished words. TODO: write this! -
clone
Clone the text format
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-