/** * Utilities for converting visually ordered RTL text (as stored inside PDF content * streams) into logical Unicode reading order, and for normalizing Arabic * presentation forms back to their base Unicode code points. * * @private */ /** * Checks whether the character is an Arabic presentation form (isolated, final, * initial or medial shape) in the Arabic Presentation Forms A/B blocks. * * @param {string} ch - Character to check. * @returns {boolean} True when the character is an Arabic presentation form. * @private */ export declare function _isArabicPresentationForm(ch: string): boolean; /** * Checks whether the character belongs to a right-to-left script (Arabic, Hebrew, * Syriac, Thaana and related presentation blocks). * * @param {string} ch - Character to check. * @returns {boolean} True when the character is an RTL character. * @private */ export declare function _isRtlCharacter(ch: string): boolean; /** * Checks whether the character is a neutral character (space, punctuation) that * takes its direction from surrounding strong characters. * * @param {string} ch - Character to check. * @returns {boolean} True when the character is directionally neutral. * @private */ export declare function _isNeutralCharacter(ch: string): boolean; /** * Checks whether the character is a left-to-right character (Latin letters, * digits and other common LTR characters). * * @param {string} ch - Character to check. * @returns {boolean} True when the character is an LTR character. * @private */ export declare function _isLtrCharacter(ch: string): boolean; /** * Maps Arabic presentation form characters (U+FB50–U+FDFF, U+FE70–U+FEFF) to their * base Arabic code points (U+0600–U+06FF and supplement ranges). Ligature * presentation forms are mapped to their multi-character logical equivalents. * * @param {string} ch - Character to normalize. * @returns {string} The base (logical) Unicode representation of the character. * @private */ export declare function _normalizeArabicCharacter(ch: string): string; /** * Converts visually ordered text containing RTL content into logical Unicode order. * LTR runs are left untouched, so mixed RTL/LTR text is preserved. Characters are * handled as UTF-16 code units to match the rest of the extraction pipeline. * * @param {string} text - Text in visual order as extracted from the PDF content stream. * @returns {string} Text in logical reading order. * @private */ export declare function _convertVisualToLogicalOrder(text: string): string; /** * Swaps mirrored paired bracket characters (parentheses, square brackets, curly * braces, angle quotes) back to their logical pair member. RTL visual layout * paints these glyphs mirrored (Unicode BiDi rule L4), so a visual-order line * must be un-mirrored to yield the logical text Adobe extracts. * * @param {string} text - Text containing mirrored bracket glyphs. * @returns {string} Text with pair members swapped back. * @private */ export declare function _unmirrorPairedBrackets(text: string): string; /** * Converts a visual-order fragment that contains no RTL characters (Latin * tokens, digits, neutral punctuation) into logical order for an RTL line. * * @param {string} text - Fragment in visual order. * @returns {string} Fragment in logical order (bracket glyphs unchanged). * @private */ export declare function _invertVisualLtrFragment(text: string): string; /** * Resolves paired-bracket glyph mirroring for a logical-order RTL line. * * @param {string} text - Line text in logical order. * @returns {string} Text with mirrored bracket glyphs restored when needed. * @private */ export declare function _resolveMirroredBrackets(text: string): string; /** * Converts visually ordered RTL text into logical order and normalizes Arabic * presentation forms to their base Unicode code points. This produces text * comparable to Adobe text extraction for Arabic, Hebrew, Persian and Urdu. * * @param {string} text - Text in visual order as extracted from the PDF. * @returns {string} Normalized text in logical reading order. * @private */ export declare function _normalizeRtlText(text: string): string; /** * Checks whether the given string contains any RTL script character. * * @param {string} text - Text to inspect. * @returns {boolean} True when the text contains an RTL character. * @private */ export declare function _containsRtlCharacter(text: string): boolean; /** * Checks whether the given text contains at least one Arabic presentation form * character. Producers that store text in visual glyph order typically emit * presentation forms, so this is used as a visual-order signal. * * @param {string} text - Text to inspect. * @returns {boolean} True when a presentation form character is present. * @private */ export declare function _containsArabicPresentationForm(text: string): boolean; /** * Maps Arabic presentation form characters in the given text to their base * Unicode code points WITHOUT any reordering. Used when the text is already * in logical order and only character normalization is needed. * * @param {string} text - Text to map. * @returns {string} Text with presentation forms replaced by base characters. * @private */ export declare function _mapArabicPresentationForms(text: string): string; /** * Determines whether the given RTL text is stored in visual (right-to-left * glyph) order rather than logical order, using the horizontal position of * consecutive glyphs/words. When the second fragment is placed to the RIGHT of * the first fragment, the text advances leftward and is visual-ordered RTL. * * @param {{ x: number, width: number }} firstBounds - Bounds of the earlier extracted fragment. * @param {number} firstBounds.x - X-coordinate of the first fragment. * @param {number} firstBounds.width - Width of the first fragment. * @param {{ x: number, width: number }} secondBounds - Bounds of the next extracted fragment. * @param {number} secondBounds.x - X-coordinate of the second fragment. * @param {number} secondBounds.width - Width of the second fragment. * @returns {boolean} True when the fragments indicate visual RTL ordering. * @private */ export declare function _isVisualOrderRtl(firstBounds: { x: number; width: number; }, secondBounds: { x: number; width: number; }): boolean; /** * Normalizes a search input string for comparison. Search input is expected in * logical order; Arabic presentation forms are mapped to base code points so a * search value typed in logical Arabic matches extracted logical text. * * @param {string} text - Search text to normalize. * @returns {string} Normalized search text. * @private */ export declare function _normalizeSearchText(text: string): string; /** * Extracted text fragment with bounds used for RTL reading-order reconstruction. * * @private */ export declare type _TextFragment = { text: string; bounds: { x: number; y: number; width: number; height: number; }; }; /** * Rebuilds reading order for extracted fragments: groups fragments that share * the same baseline (row) and, for rows containing RTL content, emits the * right-most fragment first (Adobe-style RTL line reconstruction). LTR-only * rows keep the original (left-to-right) order. * * @param {_TextFragment[]} fragments - Fragments in content stream order. * @returns {_TextFragment[]} Fragments in reading order. * @private */ export declare function _reorderFragmentsForRtlReading(fragments: _TextFragment[]): _TextFragment[];