Package com.pdftools.toolbox.pdf.content
Class TextFragment
- java.lang.Object
-
- com.pdftools.toolbox.internal.NativeBase
-
- com.pdftools.toolbox.internal.NativeObject
-
- com.pdftools.toolbox.pdf.content.TextFragment
-
- All Implemented Interfaces:
java.lang.Iterable<Glyph>,java.util.Collection<Glyph>,java.util.List<Glyph>
public class TextFragment extends NativeObject implements java.util.List<Glyph>
Text Fragment
A
TextElementcontains an arbitrary number of text fragments. Text can be partitioned arbibrarily into fragments without respecting word boundaries or reading order.A text fragment provides iteration over all contained
Glyphs. Removing, clearing, adding, and sub-ranges are not supported. While iterating, aCorruptExceptionmay be generated if the text fragment contains glyphs with inconsistent Unicode information.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, Glyph element)Not supported.booleanadd(Glyph element)Not supported.booleanaddAll(int index, java.util.Collection<? extends Glyph> elements)Not supported.booleanaddAll(java.util.Collection<? extends Glyph> elements)Not supported.voidclear()Not supported.booleancontains(java.lang.Object object)booleancontainsAll(java.util.Collection<?> objects)Glyphget(int index)RectanglegetBoundingBox()the bounding box (Getter)doublegetCharacterSpacing()The additional spacing between glyphs (Getter)FillgetFill()This text fragment's parameters for filling the text ornullif the text is not filledFontgetFont()The font (Getter)doublegetFontSize()The font size (Getter)doublegetHorizontalScaling()The horizontal scaling factor (Getter)byte[]getRawString()Raw string as an array of bytes, identical to the content stream datadoublegetRise()The rise of the baseline (Getter)StrokegetStroke()This text fragment's parameters for stroking the text ornullif the text is not strokedjava.lang.StringgetText()The string painted by this text fragmentAffineTransformgetTransform()the transform to be applied to the bounding box rectangle (Getter)doublegetWordSpacing()The additional spacing between words (Getter)WritingModegetWritingMode()The writing direction (Getter)intindexOf(java.lang.Object obj)booleanisEmpty()java.util.Iterator<Glyph>iterator()intlastIndexOf(java.lang.Object obj)java.util.ListIterator<Glyph>listIterator()java.util.ListIterator<Glyph>listIterator(int index)Glyphremove(int index)booleanremove(java.lang.Object object)booleanremoveAll(java.util.Collection<?> objects)booleanretainAll(java.util.Collection<?> objects)Glyphset(int index, Glyph element)Not supported.intsize()java.util.List<Glyph>subList(int fromIndex, int toIndex)java.lang.Object[]toArray()<T> T[]toArray(T[] array)-
Methods inherited from class com.pdftools.toolbox.internal.NativeObject
equals, hashCode
-
-
-
-
Method Detail
-
getBoundingBox
public Rectangle getBoundingBox()
the bounding box (Getter)
This is a rectangle that encompasses all parts of the text fragment.- Throws:
java.lang.IllegalStateException- the object has already been closed
-
getTransform
public AffineTransform getTransform()
the transform to be applied to the bounding box rectangle (Getter)
Use this transform matrix to compute the actual location of the text fragment's bounding box.- Throws:
java.lang.IllegalStateException- the object has already been closed
-
getText
public java.lang.String getText()
The string painted by this text fragment- Throws:
java.lang.IllegalStateException- the object has already been closed
-
getRawString
public byte[] getRawString() throws CorruptExceptionRaw string as an array of bytes, identical to the content stream data- Throws:
java.lang.IllegalStateException- the object has already been closedCorruptException- the raw string is missing or cannot be extracted
-
getStroke
public Stroke getStroke()
This text fragment's parameters for stroking the text ornullif the text is not stroked- Throws:
java.lang.IllegalStateException- the object has already been closed
-
getFill
public Fill getFill()
This text fragment's parameters for filling the text ornullif the text is not filled- Throws:
java.lang.IllegalStateException- the object has already been closed
-
getFontSize
public double getFontSize()
The font size (Getter)
- Throws:
java.lang.IllegalStateException- the object has already been closed
-
getCharacterSpacing
public double getCharacterSpacing()
The additional spacing between glyphs (Getter)
When the glyph for each character in the text is rendered, the character spacing is added to the horizontal or vertical component of the glyph's displacement, depending on the writing mode. It is subject to scaling by the horizontal scaling if the writing mode is horizontal.- Throws:
java.lang.IllegalStateException- the object has already been closed
-
getWordSpacing
public double getWordSpacing()
The additional spacing between words (Getter)
Word spacing works the same way as character spacing, but applies only to the space character, code 32.- Throws:
java.lang.IllegalStateException- the object has already been closed
-
getHorizontalScaling
public double getHorizontalScaling()
The horizontal scaling factor (Getter)
The horizontal scaling parameter adjusts the width of glyphs by stretching or compressing them in the horizontal direction. Its value is specified relative to the normal width of the glyphs, with 1 being the normal width.- Throws:
java.lang.IllegalStateException- the object has already been closed
-
getRise
public double getRise()
The rise of the baseline (Getter)
The text rise specifies the distance to move the baseline up or down from its default location. Positive values of text rise move the baseline up. Adjustments to the baseline are useful for drawing superscripts or subscripts.- Throws:
java.lang.IllegalStateException- the object has already been closed
-
getWritingMode
public WritingMode getWritingMode()
The writing direction (Getter)
This is the writing mode for the text fragment. It applies to all containedGlyphs.- Throws:
java.lang.IllegalStateException- the object has already been closed
-
getFont
public Font getFont()
The font (Getter)
The returnedFontcan only be used for extraction purposes. Specifically, using this object inTextGenerator(com.pdftools.toolbox.pdf.content.Text text, com.pdftools.toolbox.pdf.content.Font font, double fontSize, com.pdftools.toolbox.geometry.real.Point location)or inTextGenerator.setFont(com.pdftools.toolbox.pdf.content.Font)results in aIllegalArgumentExceptionerror.- Throws:
java.lang.IllegalStateException- the object has already been closed
-
addAll
public boolean addAll(java.util.Collection<? extends Glyph> elements)
Not supported.
-
addAll
public boolean addAll(int index, java.util.Collection<? extends Glyph> elements)Not supported.- Specified by:
addAllin interfacejava.util.List<Glyph>
-
contains
public boolean contains(java.lang.Object object)
-
containsAll
public boolean containsAll(java.util.Collection<?> objects)
-
isEmpty
public boolean isEmpty()
-
iterator
public java.util.Iterator<Glyph> iterator()
-
listIterator
public java.util.ListIterator<Glyph> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<Glyph>
-
listIterator
public java.util.ListIterator<Glyph> listIterator(int index)
- Specified by:
listIteratorin interfacejava.util.List<Glyph>
-
remove
public boolean remove(java.lang.Object object)
-
removeAll
public boolean removeAll(java.util.Collection<?> objects)
-
retainAll
public boolean retainAll(java.util.Collection<?> objects)
-
subList
public java.util.List<Glyph> subList(int fromIndex, int toIndex)
- Specified by:
subListin interfacejava.util.List<Glyph>
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <T> T[] toArray(T[] array)
-
size
public int size()
-
clear
public void clear()
Not supported.
-
indexOf
public int indexOf(java.lang.Object obj)
- Specified by:
indexOfin interfacejava.util.List<Glyph>
-
lastIndexOf
public int lastIndexOf(java.lang.Object obj)
- Specified by:
lastIndexOfin interfacejava.util.List<Glyph>
-
add
public boolean add(Glyph element)
Not supported.
-
add
public void add(int index, Glyph element)Not supported.- Specified by:
addin interfacejava.util.List<Glyph>
-
-