Class PdfChunk
java.lang.Object
com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfChunk
- All Implemented Interfaces:
SplitCharacter
A
PdfChunk is the PDF translation of a Chunk.
A PdfChunk is a PdfString in a certain
PdfFont and Color.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HashMapMetric 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.private static final floatprivate static final HashMapThe allowed attributes in variableattributes.private static final HashMapThe allowed attributes in variablenoStroke.protected booleantrueif the chunk split was cause by a newline.protected HashMapNon 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 PdfChunk[]protected StringThe value of this object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean(package private) Colorcolor()Returns the color of thisChunk.(package private) PdfFontfont()Returns the font of thisChunk.(package private) ObjectgetAttribute(String name) Gets an attribute.(package private) floatgetCharWidth(char c) (package private) StringGets the encoding of this string.(package private) floatGets the image offset in the y directionfloatGets the text displacement relatiev to the baseline.chargetUnicodeEquivalent(char 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) booleanisAttribute(String name) Checks if the attribute exists.(package private) booleanisExtSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) booleanChecks if thePdfChunksplit was caused by a newline.(package private) booleanTells you if this string is in Chinese, Japanese, Korean or Identity-H.booleanisSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) Checks if a character can be used to split aPdfString.(package private) booleanChecks if thisPdfChunkneeds some special metrics handling.(package private) intlength()static booleannoPrint(char c) (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.floatTrims 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.
-
Field Details
-
singleSpace
private static final char[] singleSpace -
thisChunk
-
ITALIC_ANGLE
private static final float ITALIC_ANGLE- See Also:
-
keysAttributes
The allowed attributes in variableattributes. -
keysNoStroke
The allowed attributes in variablenoStroke. -
value
The value of this object. -
encoding
The encoding. -
font
The font for thisPdfChunk. -
baseFont
-
splitCharacter
-
attributes
Metric attributes.This attributes require the mesurement of characters widths when rendering such as underline.
-
noStroke
Non metric attributes.This attributes do not require the mesurement of characters widths when rendering such as Color.
-
newlineSplit
protected boolean newlineSplittrueif the chunk split was cause by a newline. -
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
-
-
Constructor Details
-
PdfChunk
-
PdfChunk
-
-
Method Details
-
getUnicodeEquivalent
public char getUnicodeEquivalent(char 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
-
color
-
width
float width()Returns the width of thisPdfChunk.- Returns:
- a width
-
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 relatiev 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
-
getAttribute
-
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.
-
getImageOffsetY
float getImageOffsetY()Gets the image offset in the y direction- Returns:
- Gets the image offset in the y direction
-
setValue
-
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
-
length
int length() -
isSplitCharacter
Checks if a character can be used to split aPdfString.for the moment every character less than or equal to SPACE and the character '-' are 'splitCharacters'.
- Specified by:
isSplitCharacterin interfaceSplitCharacter- Parameters:
start- start position in the arraycurrent- current position in the arrayend- end position in the arraycc- the character array that has to be checkedck- chunk array- Returns:
trueif the character can be used to split a string,falseotherwise
-
isExtSplitCharacter
-
trim
-
changeLeading
public boolean changeLeading() -
getCharWidth
float getCharWidth(char c) -
noPrint
public static boolean noPrint(char c)
-