Class ColumnText
- java.lang.Object
-
- com.itextpdf.text.pdf.ColumnText
-
public class ColumnText extends java.lang.ObjectFormats text in a columnwise form. The text is bound on the left and on the right by a sequence of lines. This allows the column to have any shape, not only rectangular.Several parameters can be set like the first paragraph line indent and extra space between paragraphs.
A call to the method
gowill return one of the following situations: the column ended or the text ended.If the column ended, a new column definition can be loaded with the method
setColumnsand the methodgocan be called again.If the text ended, more text can be loaded with
addTextand the methodgocan be called again.
The only limitation is that one or more complete paragraphs must be loaded each time.Full bidirectional reordering is supported. If the run direction is
PdfWriter.RUN_DIRECTION_RTLthe meaning of the horizontal alignments and margins is mirrored.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanadjustFirstLineprotected intalignmentThe column alignment.static intAR_COMPOSEDTASHKEELCompose the tashkeel in the ligatures.static intAR_LIGDo some extra double ligatures.static intAR_NOVOWELEliminate the arabic vowelsprivate intarabicOptionsHolds value of property arabicOptions.protected BidiLinebidiLineThe chunks that form the text.protected PdfContentBytecanvasThePdfContentwhere the text will be written to.protected PdfContentByte[]canvasesprotected booleancompositeprotected ColumnTextcompositeColumnprotected java.util.LinkedList<Element>compositeElementsprotected floatcurrentLeadingThe leading for the current line.protected floatdescenderstatic intDIGIT_TYPE_ANDigit type option: Use Arabic-Indic digits (U+0660...U+0669).static intDIGIT_TYPE_AN_EXTENDEDDigit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9).static intDIGITS_AN2ENDigit shaping option: Replace Arabic-Indic digits by European digits (U+0030...U+0039).static intDIGITS_EN2ANDigit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits.static intDIGITS_EN2AN_INIT_ALDigit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC).static intDIGITS_EN2AN_INIT_LRDigit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC).protected floatextraParagraphSpaceThe extra space between paragraphs.private floatfilledWidthHolds value of property filledWidth.private floatfirstLineYprivate booleanfirstLineYDoneprotected floatfixedLeadingThe fixed text leading.protected floatfollowingIndentThe following paragraph lines indent.static floatGLOBAL_SPACE_CHAR_RATIOthe space char ratioprivate booleanignoreSpacingBeforeprotected floatindentThe first paragraph line indent.private booleaninheritGraphicStateprotected booleanisWordSplitprivate booleanlastWasNewlineprotected floatlastXThe X position after the last line that has been written.protected java.util.ArrayList<float[]>leftWallThe left column bound.protected floatleftXprotected static intLINE_STATUS_NOLINEThe line cannot fit this column position.protected static intLINE_STATUS_OFFLIMITSThe line is out the column limits.protected static intLINE_STATUS_OKThe column is valid.protected intlineStatusThe line status when trying to fit a line to a column.private intlinesWrittenHolds value of property linesWritten.protected intlistIdxprivate LoggerLOGGERprotected floatmaxYUpper bound of the column.protected floatminYLower bound of the column.protected floatmultipliedLeadingThe text leading that is multiplied by the biggest font size in the line.static intNO_MORE_COLUMNSignals that there is no more column.static intNO_MORE_TEXTSignals that there is no more text available.protected booleanrectangularModeprotected floatrectangularWidthThe width of the line when the column is defined as a simple rectangle.private booleanrepeatFirstLineIndentprotected floatrightIndentThe right paragraph lines indent.protected java.util.ArrayList<float[]>rightWallThe right column bound.protected floatrightXprotected introwIdxPointer for the row in a table that is being dealt withprotected intrunDirectionprivate floatspaceCharRatioHolds value of property spaceCharRatio.private intsplittedRowThe index of the last row that needed to be splitted.static intSTART_COLUMNInitial value of the status.private booleanuseAscenderif true, first line height is adjusted so that the max ascender touches the topprotected PhrasewaitPhraseprotected floatyLineThe current y line location.
-
Constructor Summary
Constructors Constructor Description ColumnText(PdfContentByte canvas)Creates aColumnText.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddElement(Element element)Adds an element.voidaddText(Chunk chunk)Adds aChunkto the current text array.voidaddText(Phrase phrase)Adds aPhraseto the current text array.private voidaddWaitingPhrase()voidclearChunks()Clears the chunk array.protected java.util.ArrayList<float[]>convertColumn(float[] cLine)Converts a sequence of lines representing one of the column bounds into an internal format.static ColumnTextduplicate(ColumnText org)Creates an independent duplicated of the instanceorg.protected float[]findLimitsOneLine()Finds the intersection between theyLineand the two column bounds.protected floatfindLimitsPoint(java.util.ArrayList<float[]> wall)Finds the intersection between theyLineand the column.protected float[]findLimitsTwoLines()Finds the intersection between theyLine, theyLine-leadingand the two column bounds.static floatfitText(Font font, java.lang.String text, Rectangle rect, float maxFontSize, int runDirection)Fits the text to some rectangle adjusting the font size as needed.intgetAlignment()Gets the alignment.intgetArabicOptions()Gets the arabic shaping options.PdfContentBytegetCanvas()Gets the canvas.PdfContentByte[]getCanvases()Gets the canvases.java.util.List<Element>getCompositeElements()floatgetCurrentLeading()Gets the currentLeading.floatgetDescender()Gets the biggest descender value of the last line written.floatgetExtraParagraphSpace()Sets the extra space between paragraphs.floatgetFilledWidth()Gets the real width used by the largest line.floatgetFollowingIndent()Gets the following paragraph lines indent.floatgetIndent()Gets the first paragraph line indent.booleangetInheritGraphicState()floatgetLastX()Gets the X position of the end of the last line that has been written (will not work in simulation mode!).floatgetLeading()Gets the fixed leading.intgetLinesWritten()Gets the number of lines written.floatgetMultipliedLeading()Gets the variable leading.floatgetRightIndent()Gets the right paragraph lines indent.intgetRowsDrawn()Gets the number of rows that were drawn when a table is involved.intgetRunDirection()Gets the run direction.floatgetSpaceCharRatio()Gets the space/character extra spacing ratio for fully justified text.static floatgetWidth(Phrase phrase)Gets the width that the line will occupy after writing.static floatgetWidth(Phrase phrase, int runDirection, int arabicOptions)Gets the width that the line will occupy after writing.floatgetYLine()Gets the yLine.intgo()Outputs the lines to the document.intgo(boolean simulate)Outputs the lines to the document.intgo(boolean simulate, IAccessibleElement elementToGo)protected intgoComposite(boolean simulate)static booleanhasMoreText(int status)Checks the status variable and looks if there's still some text.booleanisAdjustFirstLine()Gets the first line adjustment property.static booleanisAllowedElement(Element element)booleanisIgnoreSpacingBefore()private static booleanisTagged(PdfContentByte canvas)booleanisUseAscender()Checks if UseAscender is enabled/disabled.booleanisWordSplit()Call this after go() to know if any word was split into several lines.ColumnTextsetACopy(ColumnText org)Makes this instance an independent copy oforg.voidsetAdjustFirstLine(boolean adjustFirstLine)Sets the first line adjustment.voidsetAlignment(int alignment)Sets the alignment.voidsetArabicOptions(int arabicOptions)Sets the arabic shaping options.voidsetCanvas(PdfContentByte canvas)Sets the canvas.voidsetCanvases(PdfContentByte[] canvases)Sets the canvases.voidsetColumns(float[] leftLine, float[] rightLine)Sets the columns bounds.voidsetExtraParagraphSpace(float extraParagraphSpace)Sets the extra space between paragraphs.voidsetFilledWidth(float filledWidth)Sets the real width used by the largest line.voidsetFollowingIndent(float indent)Sets the following paragraph lines indent.voidsetIgnoreSpacingBefore(boolean ignoreSpacingBefore)voidsetIndent(float indent)Sets the first paragraph line indent.voidsetIndent(float indent, boolean repeatFirstLineIndent)Sets the first paragraph line indent.voidsetInheritGraphicState(boolean inheritGraphicState)voidsetLeading(float leading)Sets the leading to fixed.voidsetLeading(float fixedLeading, float multipliedLeading)Sets the leading fixed and variable.voidsetRightIndent(float indent)Sets the right paragraph lines indent.voidsetRunDirection(int runDirection)Sets the run direction.voidsetSimpleColumn(float llx, float lly, float urx, float ury)Simplified method for rectangular columns.voidsetSimpleColumn(float llx, float lly, float urx, float ury, float leading, int alignment)Simplified method for rectangular columns.voidsetSimpleColumn(Phrase phrase, float llx, float lly, float urx, float ury, float leading, int alignment)Simplified method for rectangular columns.voidsetSimpleColumn(Rectangle rect)Simplified method for rectangular columns.protected voidsetSimpleVars(ColumnText org)voidsetSpaceCharRatio(float spaceCharRatio)Sets the ratio between the extra word spacing and the extra character spacing when the text is fully justified.voidsetText(Phrase phrase)Replaces the current text array with thisPhrase.voidsetUseAscender(boolean useAscender)Enables/Disables adjustment of first line height based on max ascender.voidsetYLine(float yLine)Sets the yLine.static voidshowTextAligned(PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation)Shows a line of text.static voidshowTextAligned(PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation, int runDirection, int arabicOptions)Shows a line of text.voidupdateFilledWidth(float w)Replaces thefilledWidthif greater than the existing one.booleanzeroHeightElement()Checks if the element has a height of 0.
-
-
-
Field Detail
-
LOGGER
private final Logger LOGGER
-
AR_NOVOWEL
public static final int AR_NOVOWEL
Eliminate the arabic vowels- See Also:
- Constant Field Values
-
AR_COMPOSEDTASHKEEL
public static final int AR_COMPOSEDTASHKEEL
Compose the tashkeel in the ligatures.- See Also:
- Constant Field Values
-
AR_LIG
public static final int AR_LIG
Do some extra double ligatures.- See Also:
- Constant Field Values
-
DIGITS_EN2AN
public static final int DIGITS_EN2AN
Digit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits.- See Also:
- Constant Field Values
-
DIGITS_AN2EN
public static final int DIGITS_AN2EN
Digit shaping option: Replace Arabic-Indic digits by European digits (U+0030...U+0039).- See Also:
- Constant Field Values
-
DIGITS_EN2AN_INIT_LR
public static final int DIGITS_EN2AN_INIT_LR
Digit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC). The initial state at the start of the text is assumed to be not an Arabic, letter, so European digits at the start of the text will not change. Compare to DIGITS_ALEN2AN_INIT_AL.- See Also:
- Constant Field Values
-
DIGITS_EN2AN_INIT_AL
public static final int DIGITS_EN2AN_INIT_AL
Digit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC). The initial state at the start of the text is assumed to be an Arabic, letter, so European digits at the start of the text will change. Compare to DIGITS_ALEN2AN_INT_LR.- See Also:
- Constant Field Values
-
DIGIT_TYPE_AN
public static final int DIGIT_TYPE_AN
Digit type option: Use Arabic-Indic digits (U+0660...U+0669).- See Also:
- Constant Field Values
-
DIGIT_TYPE_AN_EXTENDED
public static final int DIGIT_TYPE_AN_EXTENDED
Digit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9).- See Also:
- Constant Field Values
-
runDirection
protected int runDirection
-
GLOBAL_SPACE_CHAR_RATIO
public static final float GLOBAL_SPACE_CHAR_RATIO
the space char ratio- See Also:
- Constant Field Values
-
START_COLUMN
public static final int START_COLUMN
Initial value of the status.- See Also:
- Constant Field Values
-
NO_MORE_TEXT
public static final int NO_MORE_TEXT
Signals that there is no more text available.- See Also:
- Constant Field Values
-
NO_MORE_COLUMN
public static final int NO_MORE_COLUMN
Signals that there is no more column.- See Also:
- Constant Field Values
-
LINE_STATUS_OK
protected static final int LINE_STATUS_OK
The column is valid.- See Also:
- Constant Field Values
-
LINE_STATUS_OFFLIMITS
protected static final int LINE_STATUS_OFFLIMITS
The line is out the column limits.- See Also:
- Constant Field Values
-
LINE_STATUS_NOLINE
protected static final int LINE_STATUS_NOLINE
The line cannot fit this column position.- See Also:
- Constant Field Values
-
maxY
protected float maxY
Upper bound of the column.
-
minY
protected float minY
Lower bound of the column.
-
leftX
protected float leftX
-
rightX
protected float rightX
-
alignment
protected int alignment
The column alignment. Default is left alignment.
-
leftWall
protected java.util.ArrayList<float[]> leftWall
The left column bound.
-
rightWall
protected java.util.ArrayList<float[]> rightWall
The right column bound.
-
bidiLine
protected BidiLine bidiLine
The chunks that form the text.
-
isWordSplit
protected boolean isWordSplit
-
yLine
protected float yLine
The current y line location. Text will be written at this line minus the leading.
-
lastX
protected float lastX
The X position after the last line that has been written.- Since:
- 5.0.3
-
currentLeading
protected float currentLeading
The leading for the current line.
-
fixedLeading
protected float fixedLeading
The fixed text leading.
-
multipliedLeading
protected float multipliedLeading
The text leading that is multiplied by the biggest font size in the line.
-
canvas
protected PdfContentByte canvas
ThePdfContentwhere the text will be written to.
-
canvases
protected PdfContentByte[] canvases
-
lineStatus
protected int lineStatus
The line status when trying to fit a line to a column.
-
indent
protected float indent
The first paragraph line indent.
-
followingIndent
protected float followingIndent
The following paragraph lines indent.
-
rightIndent
protected float rightIndent
The right paragraph lines indent.
-
extraParagraphSpace
protected float extraParagraphSpace
The extra space between paragraphs.
-
rectangularWidth
protected float rectangularWidth
The width of the line when the column is defined as a simple rectangle.
-
rectangularMode
protected boolean rectangularMode
-
spaceCharRatio
private float spaceCharRatio
Holds value of property spaceCharRatio.
-
lastWasNewline
private boolean lastWasNewline
-
repeatFirstLineIndent
private boolean repeatFirstLineIndent
-
linesWritten
private int linesWritten
Holds value of property linesWritten.
-
firstLineY
private float firstLineY
-
firstLineYDone
private boolean firstLineYDone
-
arabicOptions
private int arabicOptions
Holds value of property arabicOptions.
-
descender
protected float descender
-
composite
protected boolean composite
-
compositeColumn
protected ColumnText compositeColumn
-
compositeElements
protected java.util.LinkedList<Element> compositeElements
-
listIdx
protected int listIdx
-
rowIdx
protected int rowIdx
Pointer for the row in a table that is being dealt with- Since:
- 5.1.0
-
splittedRow
private int splittedRow
The index of the last row that needed to be splitted. -2 value mean it is the first attempt to split the first row. -1 means that we try to avoid splitting current row.- Since:
- 5.0.1 changed a boolean into an int
-
waitPhrase
protected Phrase waitPhrase
-
useAscender
private boolean useAscender
if true, first line height is adjusted so that the max ascender touches the top
-
filledWidth
private float filledWidth
Holds value of property filledWidth.
-
adjustFirstLine
private boolean adjustFirstLine
-
inheritGraphicState
private boolean inheritGraphicState
- Since:
- 5.4.2
-
ignoreSpacingBefore
private boolean ignoreSpacingBefore
-
-
Constructor Detail
-
ColumnText
public ColumnText(PdfContentByte canvas)
Creates aColumnText.- Parameters:
canvas- the place where the text will be written to. Can be a template.
-
-
Method Detail
-
duplicate
public static ColumnText duplicate(ColumnText org)
Creates an independent duplicated of the instanceorg.- Parameters:
org- the originalColumnText- Returns:
- the duplicated
-
setACopy
public ColumnText setACopy(ColumnText org)
Makes this instance an independent copy oforg.- Parameters:
org- the originalColumnText- Returns:
- itself
-
setSimpleVars
protected void setSimpleVars(ColumnText org)
-
addWaitingPhrase
private void addWaitingPhrase()
-
addText
public void addText(Phrase phrase)
Adds aPhraseto the current text array. Will not have any effect if addElement() was called before.- Parameters:
phrase- the text
-
setText
public void setText(Phrase phrase)
Replaces the current text array with thisPhrase. Anything added previously with addElement() is lost.- Parameters:
phrase- the text
-
addText
public void addText(Chunk chunk)
Adds aChunkto the current text array. Will not have any effect if addElement() was called before.- Parameters:
chunk- the text
-
addElement
public void addElement(Element element)
Adds an element. Elements supported areParagraph,List,PdfPTableandImage. Also accepts aChunkand aPhrase, they are placed in a newParagraph.It removes all the text placed with
addText().- Parameters:
element- theElement
-
isAllowedElement
public static boolean isAllowedElement(Element element)
-
convertColumn
protected java.util.ArrayList<float[]> convertColumn(float[] cLine)
Converts a sequence of lines representing one of the column bounds into an internal format.Each array element will contain a
float[4]representing the line x = ax + b.- Parameters:
cLine- the column array- Returns:
- the converted array
-
findLimitsPoint
protected float findLimitsPoint(java.util.ArrayList<float[]> wall)
Finds the intersection between theyLineand the column. It will set thelineStatusappropriately.- Parameters:
wall- the column to intersect- Returns:
- the x coordinate of the intersection
-
findLimitsOneLine
protected float[] findLimitsOneLine()
Finds the intersection between theyLineand the two column bounds. It will set thelineStatusappropriately.- Returns:
- a
float[2]with the x coordinates of the intersection
-
findLimitsTwoLines
protected float[] findLimitsTwoLines()
Finds the intersection between theyLine, theyLine-leadingand the two column bounds. It will set thelineStatusappropriately.- Returns:
- a
float[4]with the x coordinates of the intersection
-
setColumns
public void setColumns(float[] leftLine, float[] rightLine)Sets the columns bounds. Each column bound is described by afloat[]with the line points [x1,y1,x2,y2,...]. The array must have at least 4 elements.- Parameters:
leftLine- the left column boundrightLine- the right column bound
-
setSimpleColumn
public void setSimpleColumn(Phrase phrase, float llx, float lly, float urx, float ury, float leading, int alignment)
Simplified method for rectangular columns.- Parameters:
phrase- aPhrasellx- the lower left x cornerlly- the lower left y cornerurx- the upper right x cornerury- the upper right y cornerleading- the leadingalignment- the column alignment
-
setSimpleColumn
public void setSimpleColumn(float llx, float lly, float urx, float ury, float leading, int alignment)Simplified method for rectangular columns.- Parameters:
llx- the lower left x cornerlly- the lower left y cornerurx- the upper right x cornerury- the upper right y cornerleading- the leadingalignment- the column alignment
-
setSimpleColumn
public void setSimpleColumn(float llx, float lly, float urx, float ury)Simplified method for rectangular columns.- Parameters:
llx-lly-urx-ury-
-
setSimpleColumn
public void setSimpleColumn(Rectangle rect)
Simplified method for rectangular columns.- Parameters:
rect- the rectangle for the column
-
setLeading
public void setLeading(float leading)
Sets the leading to fixed.- Parameters:
leading- the leading
-
setLeading
public void setLeading(float fixedLeading, float multipliedLeading)Sets the leading fixed and variable. The resultant leading will be fixedLeading+multipliedLeading*maxFontSize where maxFontSize is the size of the biggest font in the line.- Parameters:
fixedLeading- the fixed leadingmultipliedLeading- the variable leading
-
getLeading
public float getLeading()
Gets the fixed leading.- Returns:
- the leading
-
getMultipliedLeading
public float getMultipliedLeading()
Gets the variable leading.- Returns:
- the leading
-
setYLine
public void setYLine(float yLine)
Sets the yLine. The line will be written to yLine-leading.- Parameters:
yLine- the yLine
-
getYLine
public float getYLine()
Gets the yLine.- Returns:
- the yLine
-
getRowsDrawn
public int getRowsDrawn()
Gets the number of rows that were drawn when a table is involved.
-
setAlignment
public void setAlignment(int alignment)
Sets the alignment.- Parameters:
alignment- the alignment
-
getAlignment
public int getAlignment()
Gets the alignment.- Returns:
- the alignment
-
setIndent
public void setIndent(float indent)
Sets the first paragraph line indent.- Parameters:
indent- the indent
-
setIndent
public void setIndent(float indent, boolean repeatFirstLineIndent)Sets the first paragraph line indent.- Parameters:
indent- the indentrepeatFirstLineIndent- do we need to repeat the indentation of the first line after a newline?
-
getIndent
public float getIndent()
Gets the first paragraph line indent.- Returns:
- the indent
-
setFollowingIndent
public void setFollowingIndent(float indent)
Sets the following paragraph lines indent.- Parameters:
indent- the indent
-
getFollowingIndent
public float getFollowingIndent()
Gets the following paragraph lines indent.- Returns:
- the indent
-
setRightIndent
public void setRightIndent(float indent)
Sets the right paragraph lines indent.- Parameters:
indent- the indent
-
getRightIndent
public float getRightIndent()
Gets the right paragraph lines indent.- Returns:
- the indent
-
getCurrentLeading
public float getCurrentLeading()
Gets the currentLeading.- Returns:
- the currentLeading
-
getInheritGraphicState
public boolean getInheritGraphicState()
-
setInheritGraphicState
public void setInheritGraphicState(boolean inheritGraphicState)
-
isIgnoreSpacingBefore
public boolean isIgnoreSpacingBefore()
-
setIgnoreSpacingBefore
public void setIgnoreSpacingBefore(boolean ignoreSpacingBefore)
-
go
public int go() throws DocumentExceptionOutputs the lines to the document. It is equivalent togo(false).- Returns:
- returns the result of the operation. It can be
NO_MORE_TEXTand/orNO_MORE_COLUMN - Throws:
DocumentException- on error
-
go
public int go(boolean simulate) throws DocumentExceptionOutputs the lines to the document. The output can be simulated.- Parameters:
simulate-trueto simulate the writing to the document- Returns:
- returns the result of the operation. It can be
NO_MORE_TEXTand/orNO_MORE_COLUMN - Throws:
DocumentException- on error
-
go
public int go(boolean simulate, IAccessibleElement elementToGo) throws DocumentException- Throws:
DocumentException
-
isWordSplit
public boolean isWordSplit()
Call this after go() to know if any word was split into several lines.- Returns:
-
getExtraParagraphSpace
public float getExtraParagraphSpace()
Sets the extra space between paragraphs.- Returns:
- the extra space between paragraphs
-
setExtraParagraphSpace
public void setExtraParagraphSpace(float extraParagraphSpace)
Sets the extra space between paragraphs.- Parameters:
extraParagraphSpace- the extra space between paragraphs
-
clearChunks
public void clearChunks()
Clears the chunk array. A call togo()will always return NO_MORE_TEXT.
-
getSpaceCharRatio
public float getSpaceCharRatio()
Gets the space/character extra spacing ratio for fully justified text.- Returns:
- the space/character extra spacing ratio
-
setSpaceCharRatio
public void setSpaceCharRatio(float spaceCharRatio)
Sets the ratio between the extra word spacing and the extra character spacing when the text is fully justified. Extra word spacing will growspaceCharRatiotimes more than extra character spacing. If the ratio isPdfWriter.NO_SPACE_CHAR_RATIOthen the extra character spacing will be zero.- Parameters:
spaceCharRatio- the ratio between the extra word spacing and the extra character spacing
-
setRunDirection
public void setRunDirection(int runDirection)
Sets the run direction.- Parameters:
runDirection- the run direction
-
getRunDirection
public int getRunDirection()
Gets the run direction.- Returns:
- the run direction
-
getLinesWritten
public int getLinesWritten()
Gets the number of lines written.- Returns:
- the number of lines written
-
getLastX
public float getLastX()
Gets the X position of the end of the last line that has been written (will not work in simulation mode!).- Since:
- 5.0.3
-
getArabicOptions
public int getArabicOptions()
Gets the arabic shaping options.- Returns:
- the arabic shaping options
-
setArabicOptions
public void setArabicOptions(int arabicOptions)
Sets the arabic shaping options. The option can be AR_NOVOWEL, AR_COMPOSEDTASHKEEL and AR_LIG.- Parameters:
arabicOptions- the arabic shaping options
-
getDescender
public float getDescender()
Gets the biggest descender value of the last line written.- Returns:
- the biggest descender value of the last line written
-
getWidth
public static float getWidth(Phrase phrase, int runDirection, int arabicOptions)
Gets the width that the line will occupy after writing. Only the width of the first line is returned.- Parameters:
phrase- thePhrasecontaining the linerunDirection- the run directionarabicOptions- the options for the arabic shaping- Returns:
- the width of the line
-
getWidth
public static float getWidth(Phrase phrase)
Gets the width that the line will occupy after writing. Only the width of the first line is returned.- Parameters:
phrase- thePhrasecontaining the line- Returns:
- the width of the line
-
showTextAligned
public static void showTextAligned(PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation, int runDirection, int arabicOptions)
Shows a line of text. Only the first line is written.- Parameters:
canvas- where the text is to be written toalignment- the alignment. It is not influenced by the run directionphrase- thePhrasewith the textx- the x reference positiony- the y reference positionrotation- the rotation to be applied in degrees counterclockwiserunDirection- the run directionarabicOptions- the options for the arabic shaping
-
showTextAligned
public static void showTextAligned(PdfContentByte canvas, int alignment, Phrase phrase, float x, float y, float rotation)
Shows a line of text. Only the first line is written.- Parameters:
canvas- where the text is to be written toalignment- the alignmentphrase- thePhrasewith the textx- the x reference positiony- the y reference positionrotation- the rotation to be applied in degrees counterclockwise
-
fitText
public static float fitText(Font font, java.lang.String text, Rectangle rect, float maxFontSize, int runDirection)
Fits the text to some rectangle adjusting the font size as needed.- Parameters:
font- the font to usetext- the textrect- the rectangle where the text must fitmaxFontSize- the maximum font sizerunDirection- the run direction- Returns:
- the calculated font size that makes the text fit
-
goComposite
protected int goComposite(boolean simulate) throws DocumentException- Throws:
DocumentException
-
getCanvas
public PdfContentByte getCanvas()
Gets the canvas. If a set of four canvases exists, the TEXTCANVAS is returned.- Returns:
- a PdfContentByte.
-
setCanvas
public void setCanvas(PdfContentByte canvas)
Sets the canvas. If before a set of four canvases was set, it is being unset.- Parameters:
canvas-
-
setCanvases
public void setCanvases(PdfContentByte[] canvases)
Sets the canvases.- Parameters:
canvases-
-
getCanvases
public PdfContentByte[] getCanvases()
Gets the canvases.- Returns:
- an array of PdfContentByte
-
zeroHeightElement
public boolean zeroHeightElement()
Checks if the element has a height of 0.- Returns:
- true or false
- Since:
- 2.1.2
-
getCompositeElements
public java.util.List<Element> getCompositeElements()
-
isUseAscender
public boolean isUseAscender()
Checks if UseAscender is enabled/disabled.- Returns:
- true is the adjustment of the first line height is based on max ascender.
-
setUseAscender
public void setUseAscender(boolean useAscender)
Enables/Disables adjustment of first line height based on max ascender.- Parameters:
useAscender- enable adjustment if true
-
hasMoreText
public static boolean hasMoreText(int status)
Checks the status variable and looks if there's still some text.
-
getFilledWidth
public float getFilledWidth()
Gets the real width used by the largest line.- Returns:
- the real width used by the largest line
-
setFilledWidth
public void setFilledWidth(float filledWidth)
Sets the real width used by the largest line. Only used to set it to zero to start another measurement.- Parameters:
filledWidth- the real width used by the largest line
-
updateFilledWidth
public void updateFilledWidth(float w)
Replaces thefilledWidthif greater than the existing one.- Parameters:
w- the newfilledWidthif greater than the existing one
-
isAdjustFirstLine
public boolean isAdjustFirstLine()
Gets the first line adjustment property.- Returns:
- the first line adjustment property.
-
setAdjustFirstLine
public void setAdjustFirstLine(boolean adjustFirstLine)
Sets the first line adjustment. Some objects have properties, like spacing before, that behave differently if the object is the first to be written after go() or not. The first line adjustment istrueby default but can be changed if several objects are to be placed one after the other in the same column calling go() several times.- Parameters:
adjustFirstLine-trueto adjust the first line,falseotherwise
-
isTagged
private static boolean isTagged(PdfContentByte canvas)
-
-