Package com.itextpdf.text.pdf
Class PdfLine
- java.lang.Object
-
- com.itextpdf.text.pdf.PdfLine
-
public class PdfLine extends java.lang.ObjectPdfLinedefines an array withPdfChunk-objects that fit into 1 line.
-
-
Field Summary
Fields Modifier and Type Field Description protected intalignmentThe alignment of the line.protected floatheightThe height of the line.protected booleanisRTLprotected floatleftThe left indentation of the line.protected java.util.ArrayList<PdfChunk>lineThe arraylist containing the chunks.protected ListItemlistItemprotected booleannewlineSplittrueif the chunk splitting was caused by a newline.protected floatoriginalWidthThe original width.protected floattabPositionprotected TabStoptabStopprotected floattabStopAnchorPositionprotected floatwidthThe width of the line.
-
Constructor Summary
Constructors Constructor Description PdfLine(float left, float originalWidth, float remainingWidth, int alignment, boolean newlineSplit, java.util.ArrayList<PdfChunk> line, boolean isRTL)Creates a PdfLine object.PdfLine(float left, float right, int alignment, float height)Constructs a newPdfLine-object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) PdfChunkadd(PdfChunk chunk)Adds aPdfChunkto thePdfLine.(package private) PdfChunkadd(PdfChunk chunk, float currentLeading)Adds aPdfChunkto thePdfLine.private voidaddToLine(PdfChunk chunk)voidflush()floatgetAscender()Gets the maximum size of the ascender for all the fonts used in this line.PdfChunkgetChunk(int idx)Gets aPdfChunkby index.floatgetDescender()Gets the biggest descender for all the fonts used in this line.intgetLastStrokeChunk()Gets the index of the lastPdfChunkwith metric attributesintgetLineLengthUtf32()Returns the length of a line in UTF32 characters(package private) float[]getMaxSize(float fixedLeading, float multipliedLeading)Gets the difference between the "normal" leading and the maximum size (for instance when there are images in the chunk and the leading has to be taken into account).floatgetOriginalWidth()Gets the original width of the line.(package private) intgetSeparatorCount()Gets the number of separators in the line.floatgetWidthCorrected(float charSpacing, float wordSpacing)Gets a width corrected with a charSpacing and wordSpacing.booleanhasToBeJustified()Checks if this line has to be justified.(package private) floatheight()Returns the height of the line.(package private) floatindentLeft()Returns the left indentation of the line taking the alignment of the line into account.booleanisNewlineSplit()Checks if a newline caused the line split.(package private) booleanisRTL()java.util.Iterator<PdfChunk>iterator()Returns an iterator ofPdfChunks.floatlistIndent()Return the indentation needed to show the listsymbol.ListItemlistItem()ChunklistSymbol()Returns the listsymbol of this line.(package private) intnumberOfSpaces()Returns the number of space-characters in this line.voidresetAlignment()Resets the alignment of this line.(package private) voidsetExtraIndent(float extra)Adds extra indentation to the left (for Paragraph.setFirstLineIndent).voidsetListItem(ListItem listItem)Sets the listsymbol of this line.intsize()Returns the number of chunks in the line.java.lang.StringtoString()Get the string representation of what is in this line.(package private) floatwidthLeft()Returns the width that is left, after a maximum of characters is added to the line.
-
-
-
Field Detail
-
line
protected java.util.ArrayList<PdfChunk> line
The arraylist containing the chunks.
-
left
protected float left
The left indentation of the line.
-
width
protected float width
The width of the line.
-
alignment
protected int alignment
The alignment of the line.
-
height
protected float height
The height of the line.
-
newlineSplit
protected boolean newlineSplit
trueif the chunk splitting was caused by a newline.
-
originalWidth
protected float originalWidth
The original width.
-
isRTL
protected boolean isRTL
-
listItem
protected ListItem listItem
-
tabStop
protected TabStop tabStop
-
tabStopAnchorPosition
protected float tabStopAnchorPosition
-
tabPosition
protected float tabPosition
-
-
Constructor Detail
-
PdfLine
PdfLine(float left, float right, int alignment, float height)Constructs a newPdfLine-object.- Parameters:
left- the limit of the line at the leftright- the limit of the line at the rightalignment- the alignment of the lineheight- the height of the line
-
PdfLine
PdfLine(float left, float originalWidth, float remainingWidth, int alignment, boolean newlineSplit, java.util.ArrayList<PdfChunk> line, boolean isRTL)Creates a PdfLine object.- Parameters:
left- the left offsetoriginalWidth- the original width of the lineremainingWidth- bigger than 0 if the line isn't completely filledalignment- the alignment of the linenewlineSplit- was the line splitted (or does the paragraph end with this line)line- an array of PdfChunk objectsisRTL- do you have to read the line from Right to Left?
-
-
Method Detail
-
add
PdfChunk add(PdfChunk chunk, float currentLeading)
Adds aPdfChunkto thePdfLine.- Parameters:
chunk- thePdfChunkto addcurrentLeading- new value for the height of the line- Returns:
nullif the chunk could be added completely; if not aPdfChunkcontaining the part of the chunk that could not be added is returned
-
add
PdfChunk add(PdfChunk chunk)
Adds aPdfChunkto thePdfLine.- Parameters:
chunk- thePdfChunkto add- Returns:
nullif the chunk could be added completely; if not aPdfChunkcontaining the part of the chunk that could not be added is returned
-
addToLine
private void addToLine(PdfChunk chunk)
-
size
public int size()
Returns the number of chunks in the line.- Returns:
- a value
-
iterator
public java.util.Iterator<PdfChunk> iterator()
Returns an iterator ofPdfChunks.- Returns:
- an
Iterator
-
height
float height()
Returns the height of the line.- Returns:
- a value
-
indentLeft
float indentLeft()
Returns the left indentation of the line taking the alignment of the line into account.- Returns:
- a value
-
hasToBeJustified
public boolean hasToBeJustified()
Checks if this line has to be justified.- Returns:
trueif the alignment equals ALIGN_JUSTIFIED and there is some width left.
-
resetAlignment
public void resetAlignment()
Resets the alignment of this line.The alignment of the last line of for instance a
Paragraphthat has to be justified, has to be reset to ALIGN_LEFT.
-
setExtraIndent
void setExtraIndent(float extra)
Adds extra indentation to the left (for Paragraph.setFirstLineIndent).
-
widthLeft
float widthLeft()
Returns the width that is left, after a maximum of characters is added to the line.- Returns:
- a value
-
numberOfSpaces
int numberOfSpaces()
Returns the number of space-characters in this line.- Returns:
- a value
-
setListItem
public void setListItem(ListItem listItem)
Sets the listsymbol of this line.This is only necessary for the first line of a
ListItem.- Parameters:
listItem- the list symbol
-
listSymbol
public Chunk listSymbol()
Returns the listsymbol of this line.- Returns:
- a
PdfChunkif the line has a listsymbol;nullotherwise
-
listIndent
public float listIndent()
Return the indentation needed to show the listsymbol.- Returns:
- a value
-
listItem
public ListItem listItem()
-
toString
public java.lang.String toString()
Get the string representation of what is in this line.- Overrides:
toStringin classjava.lang.Object- Returns:
- a
String
-
getLineLengthUtf32
public int getLineLengthUtf32()
Returns the length of a line in UTF32 characters- Returns:
- the length in UTF32 characters
- Since:
- 2.1.2; Get changed into get in 5.0.2
-
isNewlineSplit
public boolean isNewlineSplit()
Checks if a newline caused the line split.- Returns:
trueif a newline caused the line split
-
getLastStrokeChunk
public int getLastStrokeChunk()
Gets the index of the lastPdfChunkwith metric attributes- Returns:
- the last
PdfChunkwith metric attributes
-
getChunk
public PdfChunk getChunk(int idx)
Gets aPdfChunkby index.- Parameters:
idx- the index- Returns:
- the
PdfChunkor null if beyond the array
-
getOriginalWidth
public float getOriginalWidth()
Gets the original width of the line.- Returns:
- the original width of the line
-
getMaxSize
float[] getMaxSize(float fixedLeading, float multipliedLeading)Gets the difference between the "normal" leading and the maximum size (for instance when there are images in the chunk and the leading has to be taken into account).- Returns:
- an extra leading for images
- Since:
- 2.1.5
-
isRTL
boolean isRTL()
-
getSeparatorCount
int getSeparatorCount()
Gets the number of separators in the line. Returns -1 if there's a tab in the line.- Returns:
- the number of separators in the line
- Since:
- 2.1.2
-
getWidthCorrected
public float getWidthCorrected(float charSpacing, float wordSpacing)Gets a width corrected with a charSpacing and wordSpacing.- Parameters:
charSpacing-wordSpacing-- Returns:
- a corrected width
-
getAscender
public float getAscender()
Gets the maximum size of the ascender for all the fonts used in this line.- Returns:
- maximum size of all the ascenders used in this line
-
getDescender
public float getDescender()
Gets the biggest descender for all the fonts used in this line. Note that this is a negative number.- Returns:
- maximum size of all the descenders used in this line
-
flush
public void flush()
-
-