import { PdfTagType, ScopeType } from './text-extraction/enumerator'; import { PdfDocument, _PdfDictionary, PdfPage, Rectangle } from '@syncfusion/ej2-pdf'; /** * Represents the structure element of the PDF document. * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Access the structure element of the PDF document * let rootStructureElement: PdfStructureElement = extractor.getStructureElement(); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ export declare class PdfStructureElement { /** * Internal text content collected for this structure element. * * @private */ _text: string; /** * Internal PDF dictionary backing this structure element. * * @private */ _dictionary: _PdfDictionary; /** * Internal reference to the parent structure element. * * @private */ _parent: PdfStructureElement; /** * Internal order index of the element within its parent. * * @private */ _order: number; /** * Owning PdfDocument instance. * * @private */ _document: PdfDocument; /** * Internal tag type for the element. * * @private */ _tagType: PdfTagType; /** * Internal content ids (MCIDs) associated with this element. * * @private */ _contentId: number[]; /** * Internal page dictionary reference when the element references a page. * * @private */ _pageDictionary: _PdfDictionary; /** * Internal abbreviation/expansion text for the element. * * @private */ _abbreviation: string; /** * Cached PdfPage for this element. * * @private */ _page: PdfPage; /** * Child structure elements of this element. * * @private */ _childElements: PdfStructureElement[]; /** * Internal MCID value parsed from structure content. * * @private */ _mcid: number; /** * Bounding rectangle for the element. * * @private */ _bounds: Rectangle; /** * Map of abbreviation strings keyed by MCID. * * @private */ _abbreviationCollection: Map; /** * Internal array of text fragments associated with element. * * @private */ _textCollection: string[]; /** * ActualText property. * * @private */ _actualText: string; /** * Alternate/Alt text property. * * @private */ _alternateText: string; /** * Language code associated with the element. * * @private */ _language: string; /** * Title property associated with the element. * * @private */ _title: string; /** * Scope type. * * @private */ _scope: ScopeType; /** * Gets the text of the tag (Read only). * * @returns {string} The extracted text from the structure element. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the extracted text of the structure element. * let text: string = element.text; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly text: string; /** * Gets the alternate text of the tag (Read only). * * @returns {string} The alternate text from the structure element. * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the alternate text of the structure element. * let altText: string = element.alternateText; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly alternateText: string; /** * Gets the parent element (Read only). * * @returns {PdfStructureElement} The parent PdfStructureElement. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the parent of the structure element. * let parentElement: PdfStructureElement = element.parent; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly parent: PdfStructureElement; /** * Gets the abbreviation (Read only). * * @returns {string} Abbreviation * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the abbreviation of the structure element. * let abbreviation: string = element.abbreviation; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly abbreviation: string; /** * Gets the tag type of the structure element (Read only). * * @returns {PdfTagType} The tag type of the structure element. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the tag type of the structure element. * let type: PdfTagType = element.tagType; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly tagType: PdfTagType; /** * Gets the actual text of the structure element (Read only). * * @returns {string} The actual text associated with the structure element. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the actual text of the structure element. * let actualText: string = element.actualText; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly actualText: string; /** * Gets the page associated with the structure element (Read only). * * @returns {PdfPage} The PdfPage where the structure element is located. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the page of the structure element. * let elementPage: PdfPage = element.page; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly page: PdfPage; /** * Gets the bounds of the structure element (Read only). * * @returns {Rectangle} The bounds of the structure element as an array in the format [x, y, width, height]. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the bounds of the structure element. * let elementBounds: Rectangle = element.bounds; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly bounds: Rectangle; /** * Gets the child elements of this structure element (Read only). * * @returns {PdfStructureElement[]} An array of child PdfStructureElement objects. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the child elements of the structure element. * let childElements: PdfStructureElement[] = element.childElements; * // Iterate through each child element * childElements.forEach((childElement: PdfStructureElement) => { * // Do something with each child element * }); * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly childElements: PdfStructureElement[]; /** * Gets the language of the structure element (Read only). * * @returns {string} The language code of the structure element. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the language of the structure element. * let language: string = element.language; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly language: string; /** * Gets the order of the structure element (Read only). * * @returns {number} The order index representing the position of the structure element. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the order of the structure element. * let elementOrder: number = element.order; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly order: number; /** * Gets the title of the structure element (Read only). * * @returns {string} The title of the structure element. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the title of the structure element. * let elementTitle: string = element.title; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly title: string; /** * Gets the scope type of the structure element (Read only). * * @returns {ScopeType} The scope type indicating the context or area covered by the structure element, such as row, column, or both. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data, password); * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document); * // Extract structure elements from a particular page in the PDF document * let page: PdfPage = document.getPage(0); * let pageElements: PdfStructureElement[] = extractor.getStructureElements(page); * let element: PdfStructureElement = pageElements[0]; * // Gets the scope type of the structure element. * let scopeType: ScopeType = element.scope; * // Save the document * document.save('output.pdf'); * // Destroy the document * document.destroy(); * ``` */ readonly scope: ScopeType; /** * Create and initialize a PdfStructureElement instance from raw PDF dictionaries. * * @private * @param {PdfDocument} [document] - Owning document instance. * @param {_PdfDictionary} [dictionary] - Source dictionary for this element. * @param {number} [order] - Order index within parent element. * @param {PdfStructureElement} [parent] - Parent element reference. * @returns {PdfStructureElement} Initialized structure element. */ static _load(document?: PdfDocument, dictionary?: _PdfDictionary, order?: number, parent?: PdfStructureElement): PdfStructureElement; /** * Resolve a PdfPage reference from an element (if available). * * @private * @param {PdfStructureElement} element - Element to resolve the page for. * @returns {PdfPage} Resolved page or undefined. */ _getPageFromElement(element: PdfStructureElement): PdfPage; /** * Recursively search child elements for an associated page. * * @private * @returns {PdfPage} Found page or undefined. */ _getChildPage(): PdfPage; /** * Extract tagged content text and bounds by rendering page text and mapping MCIDs. * * @private * @param {PdfStructureElement[]} elements - Array of structure elements to process. * @returns {void} Nothing. */ _getTaggedContent(elements: PdfStructureElement[]): void; /** * Adjust bounds for page rotation and element's page. * * @private * @param {PdfStructureElement} element - Element whose page rotation is considered. * @param {Rectangle} bounds - Original bounds. * @returns {Rectangle} Transformed bounds. */ _calculateBounds(element: PdfStructureElement, bounds: Rectangle): Rectangle; /** * Map a PDF tag string to the PdfTagType enum. * * @private * @param {string} value - Tag name from PDF structure (e.g. 'P', 'Figure'). * @returns {PdfTagType} Corresponding enum value. */ _getTagType(value: string): PdfTagType; /** * Parse content string/array for MCID and abbreviation (E) entries. * * @private * @param {string[]} element - Tokenized content array from structure tree. * @returns {number} Parsed MCID or -1 if none. */ _parseContent(element: string[]): number; }