Package com.itextpdf.text.pdf
Class PdfChunk
java.lang.Object
com.itextpdf.text.pdf.PdfChunk
A
PdfChunk is the PDF translation of a Chunk.
A PdfChunk is a PdfString in a certain
PdfFont and BaseColor.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IAccessibleElementMetric attributes.protected BaseFontprotected booleanIndicates if the height and offset of the Image has to be taken into accountprotected StringThe encoding.protected PdfFontThe font for thisPdfChunk.protected ImageThe image in thisPdfChunk, if it has oneprotected floatprivate static final floatThe allowed attributes in variableattributes.The allowed attributes in variablenoStroke.protected floatThe leading that can overrule the existing leading.protected booleantrueif the chunk split was cause by a newline.Non metric attributes.protected floatThe offset in the x direction for the imageprotected floatThe offset in the y direction for the imageprivate static final char[]protected SplitCharacterprivate static final Stringstatic final floatstatic final floatprotected StringThe value of this object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidadjustLeft(float newValue) Deprecated.boolean(package private) BaseColorcolor()Returns the color of thisChunk.(package private) PdfFontfont()Returns the font of thisChunk.(package private) ObjectgetAttribute(String name) Gets an attribute.(package private) floatgetCharWidth(int c) (package private) StringGets the encoding of this string.(package private) ImagegetImage()Gets the image in thePdfChunk.(package private) float(package private) floatGets the image offset in the x direction(package private) floatGets the image offset in the y directionfloatReturns a scalePercentage in case the image needs to be scaled.(package private) floatfloat(package private) TabStop(package private) static TabStopgetTabStop(PdfChunk tab, float tabPosition) floatGets the text displacement relative to the baseline.intgetUnicodeEquivalent(int c) Gets the Unicode equivalent to a CID.floatgetWidthCorrected(float charSpacing, float wordSpacing) Gets the width of thePdfChunktaking into account the extra character and word spacing.protected int(package private) floatheight()(package private) booleanisAttribute(String name) Checks if the attribute exists.(package private) booleanisExtSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) (package private) booleanChecks if thisPdfChunkis a horizontal Separator Chunk.(package private) booleanisImage()Checks if there is an image in thePdfChunk.booleanChecks if thePdfChunksplit was caused by a newline.(package private) booleanChecks if thisPdfChunkis a Separator Chunk.(package private) booleanTells you if this string is in Chinese, Japanese, Korean or Identity-H.(package private) booleanChecks if thisPdfChunkneeds some special metrics handling.(package private) booleanisTab()Checks if thisPdfChunkis a tab Chunk.(package private) intlength()(package private) intstatic booleannoPrint(int c) (package private) voidsetImageOffsetX(float offsetX) Sets the image offset in the x direction(package private) voidsetImageOffsetY(float offsetY) Sets the image offset in the y directionvoidsetImageScalePercentage(float imageScalePercentage) Sets a scale percentage in case the image needs to be scaled.(package private) voidsetTabStop(TabStop tabStop) (package private) voidsets the value.(package private) PdfChunksplit(float width) Splits thisPdfChunkif it's too long for the given width.toString()(package private) StringRemoves all the ' ' and '-'-characters on the right of aString.floatfloatTrims the last space.(package private) PdfChunktruncate(float width) Truncates thisPdfChunkif it's too long for the given width.(package private) floatwidth()Returns the width of thisPdfChunk.(package private) float
-
Field Details
-
singleSpace
private static final char[] singleSpace -
ITALIC_ANGLE
private static final float ITALIC_ANGLE- See Also:
-
keysAttributes
The allowed attributes in variableattributes. -
keysNoStroke
The allowed attributes in variablenoStroke. -
TABSTOP
- See Also:
-
value
The value of this object. -
encoding
The encoding. -
font
The font for thisPdfChunk. -
baseFont
-
splitCharacter
-
attributes
Metric attributes.This attributes require the measurement of characters widths when rendering such as underline.
-
noStroke
Non metric attributes.This attributes do not require the measurement of characters widths when rendering such as BaseColor.
-
newlineSplit
protected boolean newlineSplittrueif the chunk split was cause by a newline. -
image
The image in thisPdfChunk, if it has one -
imageScalePercentage
protected float imageScalePercentage -
offsetX
protected float offsetXThe offset in the x direction for the image -
offsetY
protected float offsetYThe offset in the y direction for the image -
changeLeading
protected boolean changeLeadingIndicates if the height and offset of the Image has to be taken into account -
leading
protected float leadingThe leading that can overrule the existing leading. -
accessibleElement
-
UNDERLINE_THICKNESS
public static final float UNDERLINE_THICKNESS- See Also:
-
UNDERLINE_OFFSET
public static final float UNDERLINE_OFFSET- See Also:
-
-
Constructor Details
-
PdfChunk
Constructs aPdfChunk-object.- Parameters:
string- the content of thePdfChunk-objectother- Chunk with the same style you want for the new Chunk
-
PdfChunk
Constructs aPdfChunk-object.- Parameters:
chunk- the originalChunk-objectaction- thePdfActionif theChunkcomes from anAnchor
-
PdfChunk
PdfChunk(Chunk chunk, PdfAction action, TabSettings tabSettings) Constructs aPdfChunk-object.- Parameters:
chunk- the originalChunk-objectaction- thePdfActionif theChunkcomes from anAnchortabSettings- the Phrase tab settings
-
-
Method Details
-
getUnicodeEquivalent
public int getUnicodeEquivalent(int c) Gets the Unicode equivalent to a CID. The (inexistent) CIDis translated as '\n'. It has only meaning with CJK fonts with Identity encoding. - Parameters:
c- the CID code- Returns:
- the Unicode equivalent
-
getWord
-
split
Splits thisPdfChunkif it's too long for the given width.Returns null if the
PdfChunkwasn't truncated.- Parameters:
width- a given width- Returns:
- the
PdfChunkthat doesn't fit into the width.
-
truncate
Truncates thisPdfChunkif it's too long for the given width.Returns null if the
PdfChunkwasn't truncated.- Parameters:
width- a given width- Returns:
- the
PdfChunkthat doesn't fit into the width.
-
font
PdfFont font()Returns the font of thisChunk.- Returns:
- a
PdfFont
-
color
BaseColor color()Returns the color of thisChunk.- Returns:
- a
BaseColor
-
width
float width()Returns the width of thisPdfChunk.- Returns:
- a width
-
width
-
height
float height() -
isNewlineSplit
public boolean isNewlineSplit()Checks if thePdfChunksplit was caused by a newline.- Returns:
trueif thePdfChunksplit was caused by a newline.
-
getWidthCorrected
public float getWidthCorrected(float charSpacing, float wordSpacing) Gets the width of thePdfChunktaking into account the extra character and word spacing.- Parameters:
charSpacing- the extra character spacingwordSpacing- the extra word spacing- Returns:
- the calculated width
-
getTextRise
public float getTextRise()Gets the text displacement relative to the baseline.- Returns:
- a displacement in points
-
trimLastSpace
public float trimLastSpace()Trims the last space.- Returns:
- the width of the space trimmed, otherwise 0
-
trimFirstSpace
public float trimFirstSpace() -
getAttribute
Gets an attribute. The search is made inattributesandnoStroke.- Parameters:
name- the attribute key- Returns:
- the attribute value or null if not found
-
isAttribute
Checks if the attribute exists.- Parameters:
name- the attribute key- Returns:
trueif the attribute exists
-
isStroked
boolean isStroked()Checks if thisPdfChunkneeds some special metrics handling.- Returns:
trueif thisPdfChunkneeds some special metrics handling.
-
isSeparator
boolean isSeparator()Checks if thisPdfChunkis a Separator Chunk.- Returns:
- true if this chunk is a separator.
- Since:
- 2.1.2
-
isHorizontalSeparator
boolean isHorizontalSeparator()Checks if thisPdfChunkis a horizontal Separator Chunk.- Returns:
- true if this chunk is a horizontal separator.
- Since:
- 2.1.2
-
isTab
boolean isTab()Checks if thisPdfChunkis a tab Chunk.- Returns:
- true if this chunk is a separator.
- Since:
- 2.1.2
-
adjustLeft
Deprecated.Correction for the tab position based on the left starting position.- Parameters:
newValue- the new value for the left X.- Since:
- 2.1.2
-
getTabStop
-
getTabStop
TabStop getTabStop() -
setTabStop
-
isImage
boolean isImage()Checks if there is an image in thePdfChunk.- Returns:
trueif an image is present
-
getImage
Image getImage()Gets the image in thePdfChunk.- Returns:
- the image or
null
-
getImageHeight
float getImageHeight() -
getImageWidth
float getImageWidth() -
getImageScalePercentage
public float getImageScalePercentage()Returns a scalePercentage in case the image needs to be scaled.- Returns:
- the imageScalePercentage
-
setImageScalePercentage
public void setImageScalePercentage(float imageScalePercentage) Sets a scale percentage in case the image needs to be scaled.- Parameters:
imageScalePercentage- the imageScalePercentage to set
-
setImageOffsetX
void setImageOffsetX(float offsetX) Sets the image offset in the x direction- Parameters:
offsetX- the image offset in the x direction
-
getImageOffsetX
float getImageOffsetX()Gets the image offset in the x direction- Returns:
- the image offset in the x direction
-
setImageOffsetY
void setImageOffsetY(float offsetY) Sets the image offset in the y direction- Parameters:
offsetY- the image offset in the y direction
-
getImageOffsetY
float getImageOffsetY()Gets the image offset in the y direction- Returns:
- Gets the image offset in the y direction
-
setValue
sets the value.- Parameters:
value- content of the Chunk
-
toString
-
isSpecialEncoding
boolean isSpecialEncoding()Tells you if this string is in Chinese, Japanese, Korean or Identity-H.- Returns:
- true if the Chunk has a special encoding
-
getEncoding
String getEncoding()Gets the encoding of this string.- Returns:
- a
String
-
length
int length() -
lengthUtf32
int lengthUtf32() -
isExtSplitCharacter
-
trim
Removes all the ' ' and '-'-characters on the right of aString.- Parameters:
string- theStringthat has to be trimmed.- Returns:
- the trimmed
String
-
changeLeading
public boolean changeLeading() -
getLeading
public float getLeading() -
getCharWidth
float getCharWidth(int c) -
noPrint
public static boolean noPrint(int c)
-