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