How can I help you?
TextWord
6 Feb 20262 minutes to read
Represents a single word 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) => {
// Gets the bounds of the text word.
let wordBounds: Rectangle = textWord.bounds;
// Gets the single word of extracted text from the PDF page.
let word: string = textWord.text;
// Gets the collection of text glyphs extracted from a specified page in a PDF document.
let glyphs: TextGlyph[] = textword.glyphs;
// Gets the name of the font used for a particular word.
let wordFontName: string = textword.fontName;
// Gets the style of the font used for a particular word.
let wordFontStyle: PdfFontStyle = textword.fontStyle;
// Gets the size of the font used for a particular word.
let wordFontSize: number = textword.fontSize;
});
});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();Properties
Get bounds Rectangle
Gets the bounds of the text word.
Get fontName string
Gets the name of the font used for a particular word.
Get fontSize number
Gets the size of the font used for a particular word.
Get fontStyle PdfFontStyle
Gets the style of the font used for a particular word.
Get glyphs TextGlyph[]
Gets the collection of text glyphs extracted from a specified page in a PDF document.
Get text string
Gets the single word of extracted text from the PDF page.