Syncfusion AI Assistant

How can I help you?

TextGlyph

6 Feb 20263 minutes to read

Represents a single glyph of extracted text from the PDF page.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Initialize a new instance of the `PdfDataExtractor` class
let extractor: PdfDataExtractor = new PdfDataExtractor(document);
// Extract `TextLine` from the PDF document.
let textLines: Array<TextLine> = extractor.extractTextLines({ startPageIndex: 0, endPageIndex: document.pageCount-1});
textLines.forEach((textLine: TextLine) => {
  textLine.words.forEach((textWord: TextWord) => {
     textWord.glyphs.forEach((textGlyph: TextGlyph) => {
          // Gets the bounds of the text glyph
          let glyphBounds: Rectangle = textGlyph.bounds;
          // Gets the single character of extracted text from the PDF page.
          let character: string = textGlyph.text;
          // Gets the font size used for a particular character of the text.
          let fontSize: number = textGlyph.fontSize;
          // Gets the name of the font used for a particular character of the text.
          let fontName: string = textGlyph.fontName;
          // Gets the font style used for a particular character of the text.
          let fontStyle: PdfFontStyle = textGlyph.fontStyle;
          // Gets the text color of the text glyph.
          let color: PdfColor = textGlyph.color;
          // Gets the value indicating whether the glyph is rotated or not.
          let isRotated: boolean = textGlyph.isRotated;
     });
  });
});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();

Properties

Get bounds Rectangle

Gets the bounds of the text glyph.

Get color PdfColor

Gets the color of the text glyph.

Get fontName string

Gets the name of the font used for a particular character of the text.

Get fontSize number

Gets the font size used for a particular character of the text.

Get fontStyle PdfFontStyle

Gets the font style used for a particular character of the text.

Get isRotated boolean

Gets the value indicating whether the glyph is rotated or not.

Get text string

Gets the single character of extracted text from the PDF page.