public class

TextExtractor.Style

extends Object
implements AutoCloseable
java.lang.Object
   ↳ com.pdftron.pdf.TextExtractor.Style

Class Overview

A class representing predominant text style associated with a given Line, a Word, or a Glyph. The class includes information about the font, font size, font styles, text color, etc.

Summary

Public Methods
void close()
Frees the native memory of the object.
void destroy()
Frees the native memory of the object.
boolean equals(Object other)
Color getColor()
Get the color.
Obj getFont()
Get the font as Cos/SDF object
String getFontName()
Get the font name.
double getFontSize()
Get the font size.
int getWeight()
Get the weight.
boolean isItalic()
Checks if font is italic.
boolean isSerif()
Checks if font is serif.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.AutoCloseable

Public Methods

public void close ()

Frees the native memory of the object. This can be explicity called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

public void destroy ()

Frees the native memory of the object. This can be explicity called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

public boolean equals (Object other)

public Color getColor ()

Get the color.

Returns
  • text color in RGB color space.

public Obj getFont ()

Get the font as Cos/SDF object

Returns
  • low-level PDF font object. A high level font object can be instantiated as follows:

    com.pdftron.pdf.Font f = new com.pdftron.pdf.Font(style.getFont());

public String getFontName ()

Get the font name.

Returns
  • the font name used to draw the selected text.

public double getFontSize ()

Get the font size.

Note: Unlike the 'font size' in the graphics state (GState) the returned font size accounts for the effects CTM, text matrix, and other graphics state attributes that can affect the appearance of text.

Returns
  • The font size used to draw the selected text as it appears on the output page.

public int getWeight ()

Get the weight.

Returns
  • The weight (thickness) component of the fully-qualified font name or font specifier. The possible values are 100, 200, 300, 400, 500, 600, 700, 800, or 900, where each number indicates a weight that is at least as dark as its predecessor. A value of 400 indicates a normal weight; 700 indicates bold. Note: The specific interpretation of these values varies from font to font. For example, 300 in one font may appear most similar to 500 in another.

public boolean isItalic ()

Checks if font is italic.

Note: the return value corresponds to the state of 'italic' flag in the 'Font Descriptor'.

Returns
  • true if glyphs have dominant vertical strokes that are slanted.

public boolean isSerif ()

Checks if font is serif.

Note: the return value corresponds to the state of 'serif' flag in the 'Font Descriptor'.

Returns
  • true if glyphs have serifs, which are short strokes drawn at an angle on the top and bottom of glyph stems.