@syncfusion/ej2-pdf-data-extract 35.1.41 → 35.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ej2-pdf-data-extract.umd.min.js +2 -2
- package/dist/ej2-pdf-data-extract.umd.min.js.map +1 -1
- package/dist/ej2-pdf-lib/openjpeg.js +1 -1
- package/dist/ej2-pdf-lib/openjpeg.wasm +0 -0
- package/dist/ej2-pdf-lib/qcms.js +1 -1
- package/dist/ej2-pdf-lib/qcms_bg.wasm +0 -0
- package/dist/es6/ej2-pdf-data-extract.es2015.js +1700 -4
- package/dist/es6/ej2-pdf-data-extract.es2015.js.map +1 -1
- package/dist/es6/ej2-pdf-data-extract.es5.js +1719 -11
- package/dist/es6/ej2-pdf-data-extract.es5.js.map +1 -1
- package/dist/global/ej2-pdf-data-extract.min.js +2 -2
- package/dist/global/ej2-pdf-data-extract.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/pdf-data-extract/core/pdf-data-extractor.d.ts +83 -0
- package/src/pdf-data-extract/core/pdf-data-extractor.js +332 -8
- package/src/pdf-data-extract/core/redaction/pdf-redaction-processor.js +6 -2
- package/src/pdf-data-extract/core/rtl-utils.d.ts +186 -0
- package/src/pdf-data-extract/core/rtl-utils.js +1380 -0
- package/src/pdf-data-extract/index.d.ts +1 -0
- package/src/pdf-data-extract/index.js +1 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for converting visually ordered RTL text (as stored inside PDF content
|
|
3
|
+
* streams) into logical Unicode reading order, and for normalizing Arabic
|
|
4
|
+
* presentation forms back to their base Unicode code points.
|
|
5
|
+
*
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Checks whether the character is an Arabic presentation form (isolated, final,
|
|
10
|
+
* initial or medial shape) in the Arabic Presentation Forms A/B blocks.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} ch - Character to check.
|
|
13
|
+
* @returns {boolean} True when the character is an Arabic presentation form.
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
export declare function _isArabicPresentationForm(ch: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Checks whether the character belongs to a right-to-left script (Arabic, Hebrew,
|
|
19
|
+
* Syriac, Thaana and related presentation blocks).
|
|
20
|
+
*
|
|
21
|
+
* @param {string} ch - Character to check.
|
|
22
|
+
* @returns {boolean} True when the character is an RTL character.
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
export declare function _isRtlCharacter(ch: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Checks whether the character is a neutral character (space, punctuation) that
|
|
28
|
+
* takes its direction from surrounding strong characters.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} ch - Character to check.
|
|
31
|
+
* @returns {boolean} True when the character is directionally neutral.
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
export declare function _isNeutralCharacter(ch: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Checks whether the character is a left-to-right character (Latin letters,
|
|
37
|
+
* digits and other common LTR characters).
|
|
38
|
+
*
|
|
39
|
+
* @param {string} ch - Character to check.
|
|
40
|
+
* @returns {boolean} True when the character is an LTR character.
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
export declare function _isLtrCharacter(ch: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Maps Arabic presentation form characters (U+FB50–U+FDFF, U+FE70–U+FEFF) to their
|
|
46
|
+
* base Arabic code points (U+0600–U+06FF and supplement ranges). Ligature
|
|
47
|
+
* presentation forms are mapped to their multi-character logical equivalents.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} ch - Character to normalize.
|
|
50
|
+
* @returns {string} The base (logical) Unicode representation of the character.
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
export declare function _normalizeArabicCharacter(ch: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Converts visually ordered text containing RTL content into logical Unicode order.
|
|
56
|
+
* LTR runs are left untouched, so mixed RTL/LTR text is preserved. Characters are
|
|
57
|
+
* handled as UTF-16 code units to match the rest of the extraction pipeline.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} text - Text in visual order as extracted from the PDF content stream.
|
|
60
|
+
* @returns {string} Text in logical reading order.
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
export declare function _convertVisualToLogicalOrder(text: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Swaps mirrored paired bracket characters (parentheses, square brackets, curly
|
|
66
|
+
* braces, angle quotes) back to their logical pair member. RTL visual layout
|
|
67
|
+
* paints these glyphs mirrored (Unicode BiDi rule L4), so a visual-order line
|
|
68
|
+
* must be un-mirrored to yield the logical text Adobe extracts.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} text - Text containing mirrored bracket glyphs.
|
|
71
|
+
* @returns {string} Text with pair members swapped back.
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
export declare function _unmirrorPairedBrackets(text: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* Converts a visual-order fragment that contains no RTL characters (Latin
|
|
77
|
+
* tokens, digits, neutral punctuation) into logical order for an RTL line.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} text - Fragment in visual order.
|
|
80
|
+
* @returns {string} Fragment in logical order (bracket glyphs unchanged).
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
export declare function _invertVisualLtrFragment(text: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Resolves paired-bracket glyph mirroring for a logical-order RTL line.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} text - Line text in logical order.
|
|
88
|
+
* @returns {string} Text with mirrored bracket glyphs restored when needed.
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
export declare function _resolveMirroredBrackets(text: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Converts visually ordered RTL text into logical order and normalizes Arabic
|
|
94
|
+
* presentation forms to their base Unicode code points. This produces text
|
|
95
|
+
* comparable to Adobe text extraction for Arabic, Hebrew, Persian and Urdu.
|
|
96
|
+
*
|
|
97
|
+
* @param {string} text - Text in visual order as extracted from the PDF.
|
|
98
|
+
* @returns {string} Normalized text in logical reading order.
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
export declare function _normalizeRtlText(text: string): string;
|
|
102
|
+
/**
|
|
103
|
+
* Checks whether the given string contains any RTL script character.
|
|
104
|
+
*
|
|
105
|
+
* @param {string} text - Text to inspect.
|
|
106
|
+
* @returns {boolean} True when the text contains an RTL character.
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
export declare function _containsRtlCharacter(text: string): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Checks whether the given text contains at least one Arabic presentation form
|
|
112
|
+
* character. Producers that store text in visual glyph order typically emit
|
|
113
|
+
* presentation forms, so this is used as a visual-order signal.
|
|
114
|
+
*
|
|
115
|
+
* @param {string} text - Text to inspect.
|
|
116
|
+
* @returns {boolean} True when a presentation form character is present.
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
export declare function _containsArabicPresentationForm(text: string): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Maps Arabic presentation form characters in the given text to their base
|
|
122
|
+
* Unicode code points WITHOUT any reordering. Used when the text is already
|
|
123
|
+
* in logical order and only character normalization is needed.
|
|
124
|
+
*
|
|
125
|
+
* @param {string} text - Text to map.
|
|
126
|
+
* @returns {string} Text with presentation forms replaced by base characters.
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
129
|
+
export declare function _mapArabicPresentationForms(text: string): string;
|
|
130
|
+
/**
|
|
131
|
+
* Determines whether the given RTL text is stored in visual (right-to-left
|
|
132
|
+
* glyph) order rather than logical order, using the horizontal position of
|
|
133
|
+
* consecutive glyphs/words. When the second fragment is placed to the RIGHT of
|
|
134
|
+
* the first fragment, the text advances leftward and is visual-ordered RTL.
|
|
135
|
+
*
|
|
136
|
+
* @param {{ x: number, width: number }} firstBounds - Bounds of the earlier extracted fragment.
|
|
137
|
+
* @param {number} firstBounds.x - X-coordinate of the first fragment.
|
|
138
|
+
* @param {number} firstBounds.width - Width of the first fragment.
|
|
139
|
+
* @param {{ x: number, width: number }} secondBounds - Bounds of the next extracted fragment.
|
|
140
|
+
* @param {number} secondBounds.x - X-coordinate of the second fragment.
|
|
141
|
+
* @param {number} secondBounds.width - Width of the second fragment.
|
|
142
|
+
* @returns {boolean} True when the fragments indicate visual RTL ordering.
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
export declare function _isVisualOrderRtl(firstBounds: {
|
|
146
|
+
x: number;
|
|
147
|
+
width: number;
|
|
148
|
+
}, secondBounds: {
|
|
149
|
+
x: number;
|
|
150
|
+
width: number;
|
|
151
|
+
}): boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Normalizes a search input string for comparison. Search input is expected in
|
|
154
|
+
* logical order; Arabic presentation forms are mapped to base code points so a
|
|
155
|
+
* search value typed in logical Arabic matches extracted logical text.
|
|
156
|
+
*
|
|
157
|
+
* @param {string} text - Search text to normalize.
|
|
158
|
+
* @returns {string} Normalized search text.
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
export declare function _normalizeSearchText(text: string): string;
|
|
162
|
+
/**
|
|
163
|
+
* Extracted text fragment with bounds used for RTL reading-order reconstruction.
|
|
164
|
+
*
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
export declare type _TextFragment = {
|
|
168
|
+
text: string;
|
|
169
|
+
bounds: {
|
|
170
|
+
x: number;
|
|
171
|
+
y: number;
|
|
172
|
+
width: number;
|
|
173
|
+
height: number;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Rebuilds reading order for extracted fragments: groups fragments that share
|
|
178
|
+
* the same baseline (row) and, for rows containing RTL content, emits the
|
|
179
|
+
* right-most fragment first (Adobe-style RTL line reconstruction). LTR-only
|
|
180
|
+
* rows keep the original (left-to-right) order.
|
|
181
|
+
*
|
|
182
|
+
* @param {_TextFragment[]} fragments - Fragments in content stream order.
|
|
183
|
+
* @returns {_TextFragment[]} Fragments in reading order.
|
|
184
|
+
* @private
|
|
185
|
+
*/
|
|
186
|
+
export declare function _reorderFragmentsForRtlReading(fragments: _TextFragment[]): _TextFragment[];
|