Class PdfChunk
- java.lang.Object
-
- com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfChunk
-
- All Implemented Interfaces:
SplitCharacter
public class PdfChunk extends Object implements SplitCharacter
APdfChunkis the PDF translation of aChunk.A
PdfChunkis aPdfStringin a certainPdfFontandColor.
-
-
Field Summary
Fields Modifier and Type Field Description protected HashMapattributesMetric attributes.protected BaseFontbaseFontprotected booleanchangeLeadingIndicates if the height and offset of the Image has to be taken into accountprotected StringencodingThe encoding.protected com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfFontfontThe font for thisPdfChunk.protected booleannewlineSplittrueif the chunk split was cause by a newline.protected HashMapnoStrokeNon metric attributes.protected floatoffsetXThe offset in the x direction for the imageprotected floatoffsetYThe offset in the y direction for the imageprotected SplitCharactersplitCharacterprotected StringvalueThe value of this object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanchangeLeading()floatgetTextRise()Gets 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 intgetWord(String text, int start)booleanisNewlineSplit()Checks if thePdfChunksplit was caused by a newline.booleanisSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)Checks if a character can be used to split aPdfString.static booleannoPrint(char c)StringtoString()floattrimLastSpace()Trims the last space.
-
-
-
Field Detail
-
value
protected String value
The value of this object.
-
encoding
protected String encoding
The encoding.
-
font
protected com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfFont font
The font for thisPdfChunk.
-
baseFont
protected BaseFont baseFont
-
splitCharacter
protected SplitCharacter splitCharacter
-
attributes
protected HashMap attributes
Metric attributes.This attributes require the mesurement of characters widths when rendering such as underline.
-
noStroke
protected HashMap noStroke
Non metric attributes.This attributes do not require the mesurement of characters widths when rendering such as Color.
-
newlineSplit
protected boolean newlineSplit
trueif the chunk split was cause by a newline.
-
offsetX
protected float offsetX
The offset in the x direction for the image
-
offsetY
protected float offsetY
The offset in the y direction for the image
-
changeLeading
protected boolean changeLeading
Indicates if the height and offset of the Image has to be taken into account
-
-
Method Detail
-
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
protected int getWord(String text, int start)
-
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
-
toString
public String toString()
- Overrides:
toStringin classObject- See Also:
Object.toString()
-
isSplitCharacter
public boolean isSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)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
-
changeLeading
public boolean changeLeading()
-
noPrint
public static boolean noPrint(char c)
-
-