import { PdfFontStyle, Rectangle, PdfColor } from '@syncfusion/ej2-pdf'; /** * Represents a single line of extracted text from the PDF page. * ```typescript * // 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 = extractor.extractTextLinesSync({ 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(); * ``` */ export declare class TextLine { /** * Internal: extracted full line text. * * @private */ _text: string; /** * Internal: collection of words in this line. * * @private */ _wordCollection: TextWord[]; /** * Internal: font name used for this line. * * @private */ _fontName: string; /** * Internal: font size used for this line. * * @private */ _fontSize: number; /** * Internal: font style used for this line. * * @private */ _fontStyle: PdfFontStyle; /** * Internal: bounds of the text line. * * @private */ _bounds: Rectangle; /** * Internal: page index where this line was found. * * @private */ _pageIndex: number; /** * Gets the single line of extracted text from the PDF page. * * @returns {string} The single line of extracted text from the PDF page. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * // Gets the single line of extracted text from the PDF page. * let line: string = textLine.text; * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly text: string; /** * Gets the collection of text words extracted from a specified page in a PDF document. * * @returns {TextWord[]} The collection of text words extracted from a specified page in a PDF document. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * // Gets the collection of text words extracted from a specified page in a PDF document. * let words: TextWord[] = textLine.words; * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly words: TextWord[]; /** * Gets the name of the font used for a particular line of text. * * @returns {string} The name of the font used for a particular line of text. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * // Gets the name of the font used for a particular line of text. * let fontName: string = textLine.fontName; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly fontName: string; /** * Gets the font size used for a particular line of text. * * @returns {number} The font size used for a particular line of text. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * // 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(); * ``` */ readonly fontSize: number; /** * Gets the font style used for a particular line of text. * * @returns {PdfFontStyle} The font style used for a particular line of text. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * // Gets the font style used for a particular line of text. * let fontStyle: number = textLine.fontStyle; * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly fontStyle: PdfFontStyle; /** * Gets the bounds of the text line. * * @returns {Rectangle} The bounds of the text line. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * // Gets the bounds of the text line. * let lineBounds: Rectangle = textLine.bounds; * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly bounds: Rectangle; /** * Gets the page index of the text line extracted. * * @returns {number} Gets the page index of the text line extracted. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * // Gets the page index of the text line extracted. * let pageIndex: number = textLine.pageIndex; * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly pageIndex: number; } /** * Represents a single word of extracted text from the PDF page. * ```typescript * // 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 = extractor.extractTextLinesSync({ 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(); * ``` */ export declare class TextWord { /** * extracted word text. * * @private */ _text: string; /** * bounds of the word. * * @private */ _bounds: Rectangle; /** * glyphs composing the word. * * @private */ _glyphs: TextGlyph[]; /** * font name for the word. * * @private */ _fontName: string; /** * font size for the word. * * @private */ _fontSize: number; /** * font style for the word. * * @private */ _fontStyle: PdfFontStyle; /** * original words. * * @private */ _words: string; /** * Gets the single word of extracted text from the PDF page. * * @returns {string} The single word of extracted text from the PDF page. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * textLine.words.forEach((textWord: TextWord) => { * // Gets the single word of extracted text from the PDF page. * let word: string = textWord.text; * }); * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly text: string; /** * Gets the collection of text glyphs extracted from a specified page in a PDF document. * * @returns {TextGlyph[]} The collection of text glyphs extracted from a specified page in a PDF document. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * textLine.words.forEach((textWord: TextWord) => { * // Gets the collection of text glyphs extracted from a specified page in a PDF document. * let glyphs: TextGlyph[] = textword.glyphs; * }); * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly glyphs: TextGlyph[]; /** * Gets the name of the font used for a particular word. * * @returns {string} The name of the font used for a particular word. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * textLine.words.forEach((textWord: TextWord) => { * // Gets the name of the font used for a particular word. * let wordFontName: string = textword.fontName; * }); * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly fontName: string; /** * Gets the size of the font used for a particular word. * * @returns {number} The size of the font used for a particular word. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * textLine.words.forEach((textWord: TextWord) => { * // 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(); * ``` */ readonly fontSize: number; /** * Gets the style of the font used for a particular word. * * @returns {PdfFontStyle} The style of the font used for a particular word. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * textLine.words.forEach((textWord: TextWord) => { * // Gets the style of the font used for a particular word. * let wordFontStyle: PdfFontStyle = textword.fontStyle; * }); * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly fontStyle: PdfFontStyle; /** * Gets the bounds of the text word. * * @returns {Rectangle} The bounds of the text word. * * ```typescript * // 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 = extractor.extractTextLinesSync({ 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; * }); * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly bounds: Rectangle; } /** * Represents a single glyph of extracted text from the PDF page. * ```typescript * // 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 = extractor.extractTextLinesSync({ 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(); * ``` */ export declare class TextGlyph { /** * character text for the glyph. * * @private */ _text: string; /** * original glyph width value. * * @private */ _width: number; /** * font name for glyph. * * @private */ _fontName: string; /** * indicates whether glyph came from hex string. * * @private */ _isHex: boolean; /** * character spacing applied. * * @private */ _charSpacing: number; /** * word spacing applied. * * @private */ _wordSpacing: number; /** * font size for the glyph. * * @private */ _fontSize: number; /** * replacement marker used by redaction logic. * * @private */ _isReplace: boolean; /** * font style for the glyph. * * @private */ _fontStyle: PdfFontStyle; /** * bounding rectangle for the glyph. * * @private */ _bounds: Rectangle; /** * glyph color. * * @private */ _color: PdfColor; /** * indicates whether glyph is rotated. * * @private */ _isRotated: boolean; /** * Gets the single character of extracted text from the PDF page. * * @returns {string} The single character of extracted text from the PDF page. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * textLine.words.forEach((textWord: TextWord) => { * textWord.glyphs.forEach((textGlyph: TextGlyph) => { * // Gets the single character of extracted text from the PDF page. * let character: string = textGlyph.text; * }); * }); * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly text: string; /** * Gets the name of the font used for a particular character of the text. * * @returns {string} The name of the font used for a particular character of the text. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * textLine.words.forEach((textWord: TextWord) => { * textWord.glyphs.forEach((textGlyph: TextGlyph) => { * // Gets the name of the font used for a particular character of the text. * let fontName: string = textGlyph.fontName; * }); * }); * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly fontName: string; /** * Gets the font size used for a particular character of the text. * * @returns {number} The font size used for a particular character of the text. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * textLine.words.forEach((textWord: TextWord) => { * textWord.glyphs.forEach((textGlyph: TextGlyph) => { * // Gets the font size used for a particular character of the text. * let fontSize: number = textGlyph.fontSize; * }); * }); * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly fontSize: number; /** * Gets the font style used for a particular character of the text. * * @returns {PdfFontStyle} The font style used for a particular character of the text. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * textLine.words.forEach((textWord: TextWord) => { * // Gets the font style used for a particular character of the text. * let fontStyle: PdfFontStyle = textGlyph.fontStyle; * }); * }); * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly fontStyle: PdfFontStyle; /** * Gets the bounds of the text glyph. * * @returns {string} The bounds of the text glyph. * * ```typescript * // 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 = extractor.extractTextLinesSync({ 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; * }); * }); * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly bounds: Rectangle; /** * Gets the color of the text glyph. * * @returns {PdfColor} Text color as an array of numbers. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * textLine.words.forEach((textWord: TextWord) => { * textWord.glyphs.forEach((textGlyph: TextGlyph) => { * // Gets the text color of the text glyph. * let color: PdfColor = textGlyph.color; * }); * }); * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly color: PdfColor; /** * Gets the value indicating whether the glyph is rotated or not. * * @returns {boolean} The rotated value of text glyph. * * ```typescript * // 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 = extractor.extractTextLinesSync({ startPageIndex: 0, endPageIndex: document.pageCount-1}); * textLines.forEach((textLine: TextLine) => { * textLine.words.forEach((textWord: TextWord) => { * textWord.glyphs.forEach((textGlyph: TextGlyph) => { * // 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(); * ``` */ readonly isRotated: boolean; }