Package com.snowtide.pdf.layout
Interface Line
-
- All Superinterfaces:
Bounded,OutputSource
public interface Line extends Bounded, OutputSource
Instances of this class represent distinct runs of text at a specific position within aBlock.Note that the
TextUnits held by aLineare stored in strictly left-to-right order, and accessing them directly viagetTextUnit(int),getTextUnits()andremove(int)may result in poor outcomes if the source document contains right-to-left (RTL) or bidirectional (bidi) text. In contrast, aLine'spipemethods (e.g.OutputSource.pipe(com.snowtide.pdf.OutputHandler)) andspans(Direction)ensures that RTL and bidi text is handled properly.- Since:
- v1.4
- Version:
- ©2004-2025 Snowtide
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TextUnitgetTextUnit(int idx)Returns theTextUnitat the specified index.intgetTextUnitCnt()Returns the number ofTextUnits in this Line.List<TextUnit>getTextUnits()Returns a List view of theTextUnits held by this Line.TextUnitremove(int idx)Removes theTextUnitat the specified index, and returns it.List<Span>spans(Direction basedir)Returns a list ofSpans identified within this line of text.-
Methods inherited from interface com.snowtide.pdf.OutputSource
pipe, pipe
-
-
-
-
Method Detail
-
getTextUnitCnt
int getTextUnitCnt()
Returns the number ofTextUnits in this Line.
-
getTextUnits
List<TextUnit> getTextUnits()
Returns a List view of theTextUnits held by this Line. This List is guaranteed to provide efficient random access.
-
spans
List<Span> spans(Direction basedir)
Returns a list ofSpans identified within this line of text. This allows for directionally-aware word-by-word iteration within a line: while the {code Line}'s direct storage of characters (viagetTextUnit(int), etc) always holds them in a strictly left-to-right order, without explicitly representing spaces, theSpans returned from this method will:- Contain explicitly-represented
Spaces(as calculated by PDFxStream using adjacent characters' fonts and other metrics) - Reorder the
WordSpans in order to account for those words' aggregate directionality (eitherDirection.LTRorDirection.RTL.
- Contain explicitly-represented
-
-