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
TextElement
contains 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
Glyph
s. Removing, clearing, adding, and sub-ranges are not supported. While iterating, aCorruptException
may 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 void
add(int index, Glyph element)
Not supported.boolean
add(Glyph element)
Not supported.boolean
addAll(int index, java.util.Collection<? extends Glyph> elements)
Not supported.boolean
addAll(java.util.Collection<? extends Glyph> elements)
Not supported.void
clear()
Not supported.boolean
contains(java.lang.Object object)
boolean
containsAll(java.util.Collection<?> objects)
Glyph
get(int index)
Rectangle
getBoundingBox()
the bounding box (Getter)double
getCharacterSpacing()
The additional spacing between glyphs (Getter)Fill
getFill()
This text fragment's parameters for filling the text ornull
if the text is not filledFont
getFont()
The font (Getter)double
getFontSize()
The font size (Getter)double
getHorizontalScaling()
The horizontal scaling factor (Getter)double
getRise()
The rise of the baseline (Getter)Stroke
getStroke()
This text fragment's parameters for stroking the text ornull
if the text is not strokedjava.lang.String
getText()
The string painted by this text fragmentAffineTransform
getTransform()
the transform to be applied to the bounding box rectangle (Getter)double
getWordSpacing()
The additional spacing between words (Getter)WritingMode
getWritingMode()
The writing direction (Getter)int
indexOf(java.lang.Object obj)
boolean
isEmpty()
java.util.Iterator<Glyph>
iterator()
int
lastIndexOf(java.lang.Object obj)
java.util.ListIterator<Glyph>
listIterator()
java.util.ListIterator<Glyph>
listIterator(int index)
Glyph
remove(int index)
boolean
remove(java.lang.Object object)
boolean
removeAll(java.util.Collection<?> objects)
boolean
retainAll(java.util.Collection<?> objects)
Glyph
set(int index, Glyph element)
Not supported.int
size()
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
-
getStroke
public Stroke getStroke()
This text fragment's parameters for stroking the text ornull
if 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 ornull
if 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 containedGlyph
s.- Throws:
java.lang.IllegalStateException
- the object has already been closed
-
getFont
public Font getFont()
The font (Getter)
The returnedFont
can 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 aIllegalArgumentException
error.- 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:
addAll
in 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:
listIterator
in interfacejava.util.List<Glyph>
-
listIterator
public java.util.ListIterator<Glyph> listIterator(int index)
- Specified by:
listIterator
in 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:
subList
in 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:
indexOf
in interfacejava.util.List<Glyph>
-
lastIndexOf
public int lastIndexOf(java.lang.Object obj)
- Specified by:
lastIndexOf
in interfacejava.util.List<Glyph>
-
add
public boolean add(Glyph element)
Not supported.
-
add
public void add(int index, Glyph element)
Not supported.- Specified by:
add
in interfacejava.util.List<Glyph>
-
-