@syncfusion/ej2-pdf-data-extract 30.1.41 → 30.2.4

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.
Files changed (54) hide show
  1. package/dist/ej2-pdf-data-extract.umd.min.js +1 -2
  2. package/dist/global/ej2-pdf-data-extract.min.js +1 -2
  3. package/dist/global/index.d.ts +1 -2
  4. package/package.json +14 -46
  5. package/dist/ts/index.d.ts +0 -20
  6. package/dist/ts/index.ts +0 -20
  7. package/dist/ts/pdf-data-extract/core/content-parser-helper.d.ts +0 -62
  8. package/dist/ts/pdf-data-extract/core/content-parser-helper.ts +0 -640
  9. package/dist/ts/pdf-data-extract/core/enum.d.ts +0 -6
  10. package/dist/ts/pdf-data-extract/core/enum.ts +0 -6
  11. package/dist/ts/pdf-data-extract/core/graphic-state.d.ts +0 -33
  12. package/dist/ts/pdf-data-extract/core/graphic-state.ts +0 -106
  13. package/dist/ts/pdf-data-extract/core/pdf-data-extractor.d.ts +0 -210
  14. package/dist/ts/pdf-data-extract/core/pdf-data-extractor.ts +0 -977
  15. package/dist/ts/pdf-data-extract/core/pdf-text-parser.d.ts +0 -67
  16. package/dist/ts/pdf-data-extract/core/pdf-text-parser.ts +0 -495
  17. package/dist/ts/pdf-data-extract/core/redaction/index.d.ts +0 -4
  18. package/dist/ts/pdf-data-extract/core/redaction/index.ts +0 -4
  19. package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-processor.d.ts +0 -55
  20. package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-processor.ts +0 -592
  21. package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-region.d.ts +0 -281
  22. package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-region.ts +0 -342
  23. package/dist/ts/pdf-data-extract/core/redaction/pdf-redactor.d.ts +0 -129
  24. package/dist/ts/pdf-data-extract/core/redaction/pdf-redactor.ts +0 -322
  25. package/dist/ts/pdf-data-extract/core/redaction/text-glyph-mapper.d.ts +0 -12
  26. package/dist/ts/pdf-data-extract/core/redaction/text-glyph-mapper.ts +0 -153
  27. package/dist/ts/pdf-data-extract/core/text-extraction/binary-cmap-reader.d.ts +0 -24
  28. package/dist/ts/pdf-data-extract/core/text-extraction/binary-cmap-reader.ts +0 -281
  29. package/dist/ts/pdf-data-extract/core/text-extraction/cmap.d.ts +0 -50
  30. package/dist/ts/pdf-data-extract/core/text-extraction/cmap.ts +0 -565
  31. package/dist/ts/pdf-data-extract/core/text-extraction/compact-font-parser.d.ts +0 -191
  32. package/dist/ts/pdf-data-extract/core/text-extraction/compact-font-parser.ts +0 -1928
  33. package/dist/ts/pdf-data-extract/core/text-extraction/encoding-utils.d.ts +0 -102
  34. package/dist/ts/pdf-data-extract/core/text-extraction/encoding-utils.ts +0 -5780
  35. package/dist/ts/pdf-data-extract/core/text-extraction/font-structure.d.ts +0 -167
  36. package/dist/ts/pdf-data-extract/core/text-extraction/font-structure.ts +0 -1842
  37. package/dist/ts/pdf-data-extract/core/text-extraction/font-tables.d.ts +0 -5
  38. package/dist/ts/pdf-data-extract/core/text-extraction/font-tables.ts +0 -16
  39. package/dist/ts/pdf-data-extract/core/text-extraction/font-utils.d.ts +0 -18
  40. package/dist/ts/pdf-data-extract/core/text-extraction/font-utils.ts +0 -630
  41. package/dist/ts/pdf-data-extract/core/text-extraction/glyph.d.ts +0 -93
  42. package/dist/ts/pdf-data-extract/core/text-extraction/glyph.ts +0 -622
  43. package/dist/ts/pdf-data-extract/core/text-extraction/index.d.ts +0 -10
  44. package/dist/ts/pdf-data-extract/core/text-extraction/index.ts +0 -10
  45. package/dist/ts/pdf-data-extract/core/text-extraction/matrix-helper.d.ts +0 -38
  46. package/dist/ts/pdf-data-extract/core/text-extraction/matrix-helper.ts +0 -150
  47. package/dist/ts/pdf-data-extract/core/text-extraction/metrics.d.ts +0 -16
  48. package/dist/ts/pdf-data-extract/core/text-extraction/metrics.ts +0 -2938
  49. package/dist/ts/pdf-data-extract/core/text-structure.d.ts +0 -628
  50. package/dist/ts/pdf-data-extract/core/text-structure.ts +0 -668
  51. package/dist/ts/pdf-data-extract/core/utils.d.ts +0 -99
  52. package/dist/ts/pdf-data-extract/core/utils.ts +0 -626
  53. package/dist/ts/pdf-data-extract/index.d.ts +0 -20
  54. package/dist/ts/pdf-data-extract/index.ts +0 -20
@@ -1,67 +0,0 @@
1
- import { _PdfCrossReference, _PdfDictionary, PdfPage } from '@syncfusion/ej2-pdf';
2
- import { _GraphicState, _TextState } from './graphic-state';
3
- import { _FontStructure } from './text-extraction/font-structure';
4
- import { TextGlyph, TextLine, TextWord } from './text-structure';
5
- import { _MatrixHelper } from './text-extraction/matrix-helper';
6
- import { _PdfContentParserHelper } from './content-parser-helper';
7
- export declare class _PdfTextParser {
8
- _textGlyph: TextGlyph[];
9
- _textWord: TextWord[];
10
- _textLine: TextLine[];
11
- _extractedText: string;
12
- _width: number;
13
- _height: number;
14
- _index: number;
15
- _fontSize: number;
16
- _encodedText: string[];
17
- _previousRect: {
18
- x: number;
19
- y: number;
20
- width: number;
21
- height: number;
22
- };
23
- _boundingRectangle: {
24
- x: number;
25
- y: number;
26
- width: number;
27
- height: number;
28
- };
29
- _translateTextMatrix(x: number, y: number, textMatrix: _MatrixHelper): _MatrixHelper;
30
- _getCharacterWidth(width: number, currentFont: _FontStructure): number;
31
- _setNewLineWithLeading(textState: _TextState): void;
32
- _setTextMatrix(element: string[], textState: _TextState): void;
33
- _beginText(textState: _TextState, identityMatrix: number[]): void;
34
- _setFont(element: string[], textState: _TextState): void;
35
- _moveTextPlacementAndSetLeading(element: string[], textState: _TextState): void;
36
- _setTextRise(element: string[], textState: _TextState): void;
37
- _setCharSpacing(element: string[], textState: _TextState): void;
38
- _setWordSpacing(element: string[], textState: _TextState): void;
39
- _setTextHorizontalScale(element: string[], textState: _TextState): void;
40
- _updateTextLeading(element: string[], textState: _TextState): void;
41
- _moveTextPlacement(element: string[], textState: _TextState): void;
42
- _getCurrentTransform(font: _FontStructure, fontMatrix: number[], textState: _TextState): number[];
43
- _isFoundText(x: number, y: number, page: PdfPage, redactBounds: {
44
- x: number;
45
- y: number;
46
- width: number;
47
- height: number;
48
- }[]): boolean;
49
- _getRelativeLocation(x: number, y: number, page: PdfPage): number[];
50
- _transform(m1: number[], m2: number[]): number[];
51
- _getCropOrMediaBox(page: PdfPage): number[];
52
- _getSplitText(encodedText: string, font: _FontStructure, inputText: string[], isForRedaction?: boolean): {
53
- decodedList: string[];
54
- inputType?: string[];
55
- };
56
- _getPageRotation(textState: _TextState): number;
57
- _splitHexString(hexString: string): string[];
58
- _getFallBackFontDictionary(crossReference: _PdfCrossReference): _PdfDictionary;
59
- _processCommand(token: string, element: string[], state: _GraphicState): void;
60
- _getTextFont(fontCollection: Map<string, _FontStructure>, textState: _TextState, crossReference: _PdfCrossReference): _FontStructure;
61
- _getTextContentItem(currentFont: _FontStructure, text: string, extraSpacing: number, textState: _TextState, page: PdfPage, tempString: string, previousRect: {
62
- x: number;
63
- y: number;
64
- width: number;
65
- height: number;
66
- }, extractedText: string, parser?: _PdfContentParserHelper, textGlyphs?: TextGlyph[], hex?: string[], index?: number, encodedText?: string[]): any;
67
- }
@@ -1,495 +0,0 @@
1
- import { _PdfCrossReference, _PdfDictionary, _PdfName, PdfPage, PdfRotationAngle } from '@syncfusion/ej2-pdf';
2
- import { _GraphicState, _TextState } from './graphic-state';
3
- import { _getLiteralString, _hexToChar, _isArrayEqual, _skipEscapeSequence } from './utils';
4
- import { _FontStructure } from './text-extraction/font-structure';
5
- import { TextGlyph, TextLine, TextWord } from './text-structure';
6
- import { _MatrixHelper } from './text-extraction/matrix-helper';
7
- import { _PdfContentParserHelper } from './content-parser-helper';
8
-
9
- export class _PdfTextParser {
10
- _textGlyph: TextGlyph[] = [];
11
- _textWord: TextWord[] = [];
12
- _textLine: TextLine[] = [];
13
- _extractedText: string = '';
14
- _width: number = 0;
15
- _height: number = 0;
16
- _index: number = 0;
17
- _fontSize: number = 0;
18
- _encodedText: string[] = [];
19
- _previousRect: { x: number, y: number, width: number, height: number } = {x: 0, y: 0, width: 0 , height: 0};
20
- _boundingRectangle: { x: number, y: number, width: number, height: number } = {x: 0, y: 0, width: 0 , height: 0};
21
- _translateTextMatrix(x: number, y: number, textMatrix: _MatrixHelper): _MatrixHelper {
22
- const matrix: _MatrixHelper = new _MatrixHelper(textMatrix._m11, textMatrix._m12, textMatrix._m21, textMatrix._m22,
23
- textMatrix._m11 * x + textMatrix._m21 * y + textMatrix._offsetX,
24
- textMatrix._m12 * x + textMatrix._m22 * y + textMatrix._offsetY);
25
- return matrix;
26
- }
27
- _getCharacterWidth(width: number, currentFont: _FontStructure): number {
28
- let advancedWidth: number;
29
- if (currentFont._type === 'TrueType') {
30
- advancedWidth = width;
31
- } else {
32
- advancedWidth = 1 ;
33
- }
34
- return advancedWidth;
35
- }
36
- _setNewLineWithLeading(textState: _TextState): void {
37
- textState._carriageReturn();
38
- }
39
- _setTextMatrix(element: string[], textState: _TextState): void {
40
- textState._setTextMatrix(
41
- parseFloat(element[0]), parseFloat(element[1]), parseFloat(element[2]),
42
- parseFloat(element[3]), parseFloat(element[4]), parseFloat(element[5])
43
- );
44
- textState._setTextLineMatrix(
45
- parseFloat(element[0]), parseFloat(element[1]), parseFloat(element[2]),
46
- parseFloat(element[3]), parseFloat(element[4]), parseFloat(element[5])
47
- );
48
- }
49
- _beginText(textState: _TextState, identityMatrix: number[]): void {
50
- textState._textMatrix = identityMatrix.slice();
51
- textState._textLineMatrix = identityMatrix.slice();
52
- }
53
- _setFont(element: string[], textState: _TextState): void {
54
- for (let j: number = 0; j < element.length; j++) {
55
- if (element[Number.parseInt(j.toString(), 10)].indexOf('/') !== -1) {
56
- textState._font = element[Number.parseInt(j.toString(), 10)].replace('/', '');
57
- break;
58
- }
59
- }
60
- textState._fontSize = Number(element[1]);
61
- }
62
- _moveTextPlacementAndSetLeading(element: string[], textState: _TextState): void {
63
- textState._leading = -Number(element[1]);
64
- textState._translateTextLineMatrix(Number(element[0]), Number(element[1]));
65
- textState._textMatrix = textState._textLineMatrix.slice();
66
- }
67
- _setTextRise(element: string[], textState: _TextState): void {
68
- textState._textRise = Number(element[0]);
69
- }
70
- _setCharSpacing(element: string[], textState: _TextState): void {
71
- textState._charSpacing = Number(element[0]);
72
- }
73
- _setWordSpacing(element: string[], textState: _TextState): void {
74
- textState._wordSpacing = Number(element[0]);
75
- }
76
- _setTextHorizontalScale(element: string[], textState: _TextState): void {
77
- textState._textHScale = Number(element[0]) / 100;
78
- }
79
- _updateTextLeading(element: string[], textState: _TextState): void {
80
- textState._leading = Number(element[0]);
81
- }
82
- _moveTextPlacement(element: string[], textState: _TextState): void {
83
- textState._translateTextLineMatrix(Number(element[0]), Number(element[1]));
84
- textState._textMatrix = textState._textLineMatrix.slice();
85
- }
86
- _getCurrentTransform(font: _FontStructure, fontMatrix: number[], textState: _TextState): number[] {
87
- const tsm: number[] = [textState._fontSize * textState._textHScale, 0, 0, textState._fontSize, 0, textState._textRise];
88
- if (font._isType3Font && textState._fontSize <= 1 && !_isArrayEqual(fontMatrix, [0.001, 0, 0, 0.001, 0, 0])) {
89
- const glyphHeight: number = font._boundingBox[3] - font._boundingBox[1];
90
- if (glyphHeight > 0) {
91
- tsm[3] *= glyphHeight * fontMatrix[3];
92
- }
93
- }
94
- return this._transform(textState._ctm, this._transform(textState._textMatrix, tsm));
95
- }
96
- _isFoundText(x: number, y: number, page: PdfPage, redactBounds: {x: number, y: number, width: number, height: number}[]): boolean {
97
- let isFound: boolean = false;
98
- let location: number[] = [];
99
- if (y < 0) {
100
- y = -y;
101
- }
102
- const rectValue: {x: number, y: number, width: number, height: number} = {x: 0, y: 0, width: 0, height: 0};
103
- const redactionBounds: {x: number, y: number, width: number, height: number}[] = redactBounds;
104
- location = this._getRelativeLocation(x, y, page);
105
- let yPosition: number = Math.floor(location[1]);
106
- const count: number = redactionBounds.length;
107
- for (let i: number = 0; i < count; i++) {
108
- const bounds: {x: number, y: number, width: number, height: number} = redactionBounds[Number.parseInt(i.toString(), 10)];
109
- const ypos: number = Math.floor(redactionBounds[Number.parseInt(i.toString(), 10)].y);
110
- if (ypos === yPosition || (ypos === (yPosition - 1)) || (ypos === (yPosition + 1))) {
111
- isFound = true;
112
- break;
113
- }
114
- if ((bounds.y >= yPosition && yPosition >= (bounds.y - bounds.height)) || (bounds.y <= yPosition && yPosition <= (bounds.y
115
- + bounds.height))) {
116
- isFound = true;
117
- break;
118
- }
119
- const size: number[] = page.size;
120
- yPosition = Math.floor(size[1] - y);
121
- if ((bounds.y >= yPosition && yPosition >= (bounds.y - bounds.height)) || (bounds.y <= yPosition && yPosition <= (bounds.y +
122
- bounds.height))) {
123
- isFound = true;
124
- break;
125
- }
126
- if (rectValue.y !== 0) {
127
- if (rectValue.y < 0) {
128
- rectValue.y = -rectValue.y;
129
- }
130
- yPosition = Math.floor(y + rectValue.y);
131
- if ((bounds.y >= yPosition && yPosition >= (bounds.y - bounds.height)) || (bounds.y <= yPosition && yPosition <= (bounds.y +
132
- bounds.height))) {
133
- isFound = true;
134
- break;
135
- }
136
- if (rectValue.height < 0) {
137
- rectValue.height = -rectValue.height;
138
- }
139
- yPosition = Math.floor(rectValue.height - yPosition);
140
- if ((bounds.y >= yPosition && yPosition >= (bounds.y - bounds.height)) || (bounds.y <= yPosition && yPosition <= (bounds.y +
141
- bounds.height))) {
142
- isFound = true;
143
- break;
144
- }
145
- }
146
- }
147
- return isFound;
148
- }
149
- _getRelativeLocation(x: number, y: number , page: PdfPage): number[] {
150
- const location: number[] = [x, y];
151
- if (page.rotation === PdfRotationAngle.angle90) {
152
- location[0] = page.size[1] - y;
153
- location[1] = x;
154
- } else if (page.rotation === PdfRotationAngle.angle270) {
155
- location[0] = page.size[0] - x;
156
- location[1] = y;
157
- }
158
- return location;
159
- }
160
- _transform(m1: number[], m2: number[]): number[] {
161
- return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3]
162
- , m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
163
- }
164
- _getCropOrMediaBox(page: PdfPage): number[] {
165
- const cropOrMediaBox: number[] = [];
166
- if (page.cropBox[0] !== 0 || page.cropBox[3] !== 0) {
167
- cropOrMediaBox[0] = page.cropBox[0];
168
- cropOrMediaBox[1] = page.cropBox[2];
169
- cropOrMediaBox[2] = page.cropBox[3];
170
- } else if (page.mediaBox[0] !== 0 || page.mediaBox[3] !== 0) {
171
- cropOrMediaBox[0] = page.mediaBox[0];
172
- cropOrMediaBox[1] = page.mediaBox[2];
173
- cropOrMediaBox[2] = page.mediaBox[3];
174
- }
175
- return cropOrMediaBox;
176
- }
177
- _getSplitText(encodedText: string, font: _FontStructure, inputText: string[], isForRedaction: boolean = false): { decodedList:
178
- string[], inputType?: string[] } {
179
- const decodedList: string[] = [];
180
- let key: string = '';
181
- const encoding: string = font._encoding;
182
- const inputType: string[] = isForRedaction ? [] : undefined;
183
- let tempString: string = '';
184
- let splittedText: string[];
185
- let isHex: boolean = false;
186
- let isWidth: boolean;
187
- switch (encodedText[0]) {
188
- case '(':
189
- encodedText = encodedText.substring(1, encodedText.length - 1);
190
- if (encodedText.indexOf('\\\n') !== -1 || encodedText.indexOf('\\(') !== -1 || encodedText.indexOf('\\)') !== -1) {
191
- if (encodedText.indexOf('\\\n') !== -1) {
192
- encodedText = encodedText.replace(/\\\n/g, '');
193
- }
194
- if (encodedText.indexOf('\\(') !== -1) {
195
- encodedText = encodedText.replace(/\\\(/g, '(');
196
- }
197
- if (encodedText.indexOf('\\)') !== -1) {
198
- encodedText = encodedText.replace(/\\\)/g, ')');
199
- }
200
- }
201
- if (encodedText.indexOf('\\n') !== -1) {
202
- encodedText = encodedText.replace(/\\n/g, '\n');
203
- }
204
- if (encodedText.indexOf('\\r') !== -1) {
205
- encodedText = encodedText.replace(/\\r/g, '\r');
206
- }
207
- encodedText = _getLiteralString(encodedText, encoding);
208
- encodedText = _skipEscapeSequence(encodedText);
209
- key = encodedText + 's';
210
- decodedList.push(key);
211
- if (isForRedaction) {
212
- inputType.push(' ');
213
- }
214
- break;
215
- case '[':
216
- splittedText = inputText;
217
- isHex = false;
218
- for (let i: number = 0; i < splittedText.length; i++) {
219
- let input: string = splittedText[Number.parseInt(i.toString(), 10)];
220
- isWidth = false;
221
- if (input.indexOf('\\\n') !== -1) {
222
- input = input.replace(/\\\n/g, '');
223
- }
224
- if (input[0] === '<') {
225
- isHex = true;
226
- if (isForRedaction) {
227
- inputType.push(input);
228
- }
229
- input = input.slice(1, -1);
230
- } else if (input[0] === '(') {
231
- input = input.slice(1, -1);
232
- } else if (input.length > 0){
233
- input = input.replace('\n', '');
234
- decodedList.push(input);
235
- if (isForRedaction) {
236
- inputType.push(' ');
237
- }
238
- continue;
239
- }
240
- if (isHex) {
241
- tempString = _hexToChar(input);
242
- } else {
243
- tempString = _getLiteralString(input, encoding);
244
- if (tempString.indexOf('\\') !== -1) {
245
- tempString = _skipEscapeSequence(tempString);
246
- }
247
- }
248
- if (!isWidth && input.length > 0) {
249
- key = tempString + 's';
250
- decodedList.push(key);
251
- key = '';
252
- if (isForRedaction && !isHex) {
253
- inputType.push(' ');
254
- }
255
- isHex = false;
256
- }
257
- }
258
- break;
259
- case '<':
260
- encodedText = encodedText.substring(1, encodedText.length - 1);
261
- tempString = _hexToChar(encodedText);
262
- key = tempString + 's';
263
- decodedList.push(key);
264
- break;
265
- }
266
- return isForRedaction ? { decodedList, inputType } : { decodedList };
267
- }
268
- _getPageRotation(textState: _TextState): number {
269
- let rotation: number = 0;
270
- if (textState._textMatrix[0] === 0 && textState._textMatrix[1] > 0 && textState._textMatrix[2] < 0 &&
271
- textState._textMatrix[3] >= 0) {
272
- rotation = 90;
273
- } else if (textState._textMatrix[0] === 0 && textState._textMatrix[1] < 0 && textState._textMatrix[2] > 0
274
- && textState._textMatrix[3] === 0) {
275
- rotation = 270;
276
- }
277
- return rotation;
278
- }
279
- _splitHexString(hexString: string): string[] {
280
- const hexList: string[] = [];
281
- if (typeof(hexString) === 'undefined') {
282
- return hexList;
283
- }
284
- hexString = hexString.slice(1, -1);
285
- const size: number = hexString.startsWith('0') ? 4 : 2;
286
- for (let i: number = 0; i < hexString.length; i += size) {
287
- let chunk: string = hexString.substring(i, i + size);
288
- if (chunk.indexOf('\n') !== -1) {
289
- const extraChar: string = hexString.charAt(i + size);
290
- chunk += extraChar;
291
- i++;
292
- }
293
- hexList.push(chunk);
294
- }
295
- return hexList;
296
- }
297
- _getFallBackFontDictionary(crossReference: _PdfCrossReference): _PdfDictionary {
298
- const dictionary: _PdfDictionary = new _PdfDictionary(crossReference);
299
- dictionary.set('BaseFont', new _PdfName('Helvetica'));
300
- dictionary.set('Type', new _PdfName('FallbackType'));
301
- dictionary.set('Subtype', new _PdfName('FallbackType'));
302
- dictionary.set('Encoding', new _PdfName('WinAnsiEncoding'));
303
- return dictionary;
304
- }
305
- _processCommand(token: string, element: string[], state: _GraphicState): void {
306
- let args: number[] = [];
307
- switch (token) {
308
- case 'q':
309
- state._save();
310
- break;
311
- case 'Q':
312
- state._restore();
313
- break;
314
- case 'cm':
315
- args = [parseFloat(element[0]), parseFloat(element[1]), parseFloat(
316
- element[2]), parseFloat(element[3]), parseFloat(element[4]), parseFloat(element[5])];
317
- state._transform(args);
318
- }
319
- }
320
- _getTextFont(fontCollection: Map<string, _FontStructure>, textState: _TextState, crossReference: _PdfCrossReference): _FontStructure {
321
- let currentFont: _FontStructure;
322
- if (fontCollection.get(textState._font)) {
323
- currentFont = fontCollection.get(textState._font);
324
- } else {
325
- const dictionary: _PdfDictionary = this._getFallBackFontDictionary(crossReference);
326
- currentFont = new _FontStructure(dictionary, crossReference);
327
- }
328
- return currentFont;
329
- }
330
- _getTextContentItem(currentFont: _FontStructure, text: string, extraSpacing: number, textState: _TextState, page: PdfPage,
331
- tempString: string, previousRect: { x: number, y: number, width: number, height: number }, extractedText: string, parser?: _PdfContentParserHelper, textGlyphs?: TextGlyph[], hex?: string[], index?: number, encodedText?: string[]): any { // eslint-disable-line
332
- text = text.slice(0, -1 );
333
- let fontSize: number = 0;
334
- let isHex: boolean = false;
335
- let textBounds: { x: number, y: number, width: number, height: number } = {x: 0, y: 0, width: 0 , height: 0};
336
- if (typeof(hex) !== 'undefined' && hex.length > 0) {
337
- isHex = true;
338
- }
339
- let glyphs: any = currentFont._charsToGlyphs(text); // eslint-disable-line
340
- const ii: number = glyphs.length;
341
- let scale: number = 0;
342
- if (currentFont. _fontMatrix) {
343
- scale = currentFont._fontMatrix[0];
344
- } else {
345
- currentFont._fontMatrix = [0.001, 0, 0, 0.001, 0, 0];
346
- scale = 0.001;
347
- }
348
- const rotation: number = this._getPageRotation(textState);
349
- for (let i: number = 0; i < ii; i++) {
350
- const glyph: any = glyphs[Number.parseInt(i.toString(), 10)]; // eslint-disable-line
351
- // this._resultantText += glyph._unicode;
352
- let width: number;
353
- let charSpacing: number = textState._charSpacing + (i + 1 === ii ? extraSpacing : 0);
354
- let glyphWidth: number = glyph._width;
355
- if (currentFont._vertical) {
356
- glyphWidth = glyph.vmetric ? glyph.vmetric[0] : -glyphWidth;
357
- }
358
- let scaledDim: number = glyphWidth * scale * textState._fontSize;
359
- width = scale * glyphWidth;
360
- let height: number = 0;
361
- let tempFontSize: number = 0;
362
- const transform: number[] = this._getCurrentTransform(currentFont, currentFont._fontMatrix, textState);
363
- const cropOrMediaBox: number[] = this._getCropOrMediaBox(page);
364
- let x: number = transform[4];
365
- let y: number = 0;
366
- if (page.rotation === PdfRotationAngle.angle180 || page.rotation === PdfRotationAngle.angle270) {
367
- x = cropOrMediaBox[1] - x;
368
- } else {
369
- x = x - cropOrMediaBox[0];
370
- }
371
- if (page.rotation === PdfRotationAngle.angle90 || page.rotation === PdfRotationAngle.angle180) {
372
- y = transform[5];
373
- } else {
374
- y = cropOrMediaBox[2] - transform[5];
375
- }
376
- if (!currentFont._vertical) {
377
- height = Math.hypot(transform[2], transform[3]);
378
- } else {
379
- width = Math.hypot(transform[0], transform[1]);
380
- }
381
- if (transform[0] > 0) {
382
- tempFontSize = transform[0];
383
- } else if (transform[1] !== 0 && transform[2] !== 0) {
384
- if (transform[1] < 0) {
385
- tempFontSize = -transform[1];
386
- } else {
387
- tempFontSize = transform[1];
388
- }
389
- }
390
- if (glyph._unicode === ' ') {
391
- if (!currentFont._vertical) {
392
- charSpacing += scaledDim + textState._wordSpacing;
393
- textState._translateTextMatrix(charSpacing * (textState._textHScale), 0);
394
- width *= tempFontSize;
395
- if (rotation === 90) {
396
- y = y - width;
397
- x = x - height + height / 4 ;
398
- } else if (page.rotation === PdfRotationAngle.angle90 || page.rotation === PdfRotationAngle.angle180) {
399
- y = y - height + (height / 1.3333333333333333);
400
- } else {
401
- y = y - height / 1.3333333333333333;
402
- }
403
- } else {
404
- charSpacing += -scaledDim + textState._wordSpacing;
405
- textState._translateTextMatrix(0, -charSpacing);
406
- height += tempFontSize;
407
- x = x - width / 2;
408
- }
409
- }
410
- if (glyph._unicode !== ' ') {
411
- if (!currentFont._vertical) {
412
- scaledDim *= textState._textHScale;
413
- textState._translateTextMatrix(scaledDim, 0);
414
- width *= tempFontSize;
415
- if (rotation === 90) {
416
- y = y - width;
417
- x = x - height + height / 4 ;
418
- } else if (page.rotation === PdfRotationAngle.angle90 || page.rotation === PdfRotationAngle.angle180) {
419
- y = y - height + (height / 1.3333333333333333);
420
- } else {
421
- y = y - (height / 1.3333333333333333);
422
- }
423
- } else {
424
- textState._translateTextMatrix(0, scaledDim);
425
- scaledDim = Math.abs(scaledDim);
426
- height += scaledDim + tempFontSize;
427
- x = x - width / 2;
428
- }
429
- }
430
- if (page.rotation === PdfRotationAngle.angle0 && rotation === 90) {
431
- textBounds = {x: x, y: y, width: height, height: width};
432
- } else if (page.rotation === PdfRotationAngle.angle90) {
433
- textBounds = {x: y, y: x, width: height, height: width};
434
- } else if (page.rotation === PdfRotationAngle.angle180) {
435
- textBounds = {x: x - width, y: y, width: width, height: height};
436
- } else if (page.rotation === PdfRotationAngle.angle270) {
437
- textBounds = {x: y, y: x - width, width: height, height: width};
438
- } else {
439
- textBounds = {x: x, y: y, width: width, height: height};
440
- }
441
- extractedText += glyph._unicode;
442
- if (typeof(textGlyphs) !== 'undefined') {
443
- const bounds: { x: number, y: number, width: number, height: number } = textBounds;
444
- const textGlyph: TextGlyph = new TextGlyph();
445
- if (isHex && hex.length >= i) {
446
- textGlyph._isHex = true;
447
- encodedText[Number.parseInt(index.toString(), 10)] = hex[Number.parseInt(i.toString(), 10)];
448
- } else {
449
- encodedText[Number.parseInt(index.toString(), 10)] = glyph._fontCharacter;
450
- }
451
- textGlyph._text = glyph._unicode;
452
- textGlyph._bounds = [bounds.x, bounds.y, bounds.width, bounds.height];
453
- textGlyph._fontName = currentFont._name;
454
- textGlyph._fontStyle = currentFont._fontStyle;
455
- textGlyph._fontSize = textState._fontSize;
456
- textGlyph._color = textState._textColor;
457
- textGlyph._width = glyph._width;
458
- textGlyph._charSpacing = textState._charSpacing;
459
- textGlyph._wordSpacing = textState._wordSpacing;
460
- index++;
461
- if (page.rotation !== PdfRotationAngle.angle0) {
462
- textGlyph._isRotated = true;
463
- } else {
464
- textGlyph._isRotated = false;
465
- }
466
- textGlyphs.push(textGlyph);
467
- } else {
468
- fontSize = textState._fontSize;
469
- const result: any = parser._splitWords(glyph._unicode, tempString, currentFont._name,// eslint-disable-line
470
- currentFont._fontStyle, page, rotation, textState._textColor, textState._fontSize,
471
- textBounds, previousRect);
472
- previousRect = result.previousRect;
473
- tempString = result.tempString;
474
- if (previousRect) {
475
- previousRect = {x: textBounds.x, y: textBounds.y,
476
- width: textBounds.width, height: textBounds.height};
477
- } else {
478
- previousRect = {x: 0, y: 0, width: 0 , height: 0};
479
- }
480
- }
481
- if (charSpacing && glyph._unicode !== ' ') {
482
- if (!currentFont._vertical) {
483
- textState._translateTextMatrix(charSpacing * textState._textHScale, 0);
484
- } else {
485
- textState._translateTextMatrix(0, -charSpacing);
486
- }
487
- }
488
- }
489
- if (typeof(textGlyphs) !== 'undefined') {
490
- return {textGlyphs, extractedText, encodedText, index};
491
- } else {
492
- return {tempString, extractedText, fontSize, previousRect};
493
- }
494
- }
495
- }
@@ -1,4 +0,0 @@
1
- export * from './pdf-redaction-processor';
2
- export * from './pdf-redaction-region';
3
- export * from './pdf-redactor';
4
- export * from './text-glyph-mapper';
@@ -1,4 +0,0 @@
1
- export * from './pdf-redaction-processor';
2
- export * from './pdf-redaction-region';
3
- export * from './pdf-redactor';
4
- export * from './text-glyph-mapper';
@@ -1,55 +0,0 @@
1
- import { _PdfAnnotationType, _PdfContentStream, _PdfDictionary, PdfDocument, PdfPage } from '@syncfusion/ej2-pdf';
2
- import { PdfRedactionRegion } from './pdf-redaction-region';
3
- export declare class _PdfRedactionProcessor {
4
- _updateContentStream(page: PdfPage, stream: _PdfContentStream, options: PdfRedactionRegion[], document: PdfDocument): void;
5
- _processFormFields(page: PdfPage, options: PdfRedactionRegion[], document: PdfDocument): void;
6
- _isFound(values: number[], redactionBounds: {
7
- x: number;
8
- y: number;
9
- width: number;
10
- height: number;
11
- }): boolean;
12
- _intersectsWith(rect1: {
13
- x: number;
14
- y: number;
15
- width: number;
16
- height: number;
17
- }, rect2: {
18
- x: number;
19
- y: number;
20
- width: number;
21
- height: number;
22
- }): boolean;
23
- _isEmptyRectangle(width: number, height: number): boolean;
24
- _toRectangle(x: number, y: number, width: number, height: number): number[];
25
- _isKidInSamePage(kid: _PdfDictionary, page: PdfPage): boolean;
26
- _processAnnotation(page: PdfPage, options: PdfRedactionRegion[]): void;
27
- _getBoundsFromPoints(points: number[], loadedPage: PdfPage): {
28
- bounds: {
29
- x: number;
30
- y: number;
31
- width: number;
32
- height: number;
33
- };
34
- isValidAnnotation: boolean;
35
- };
36
- _isLineIntersectRectangle(redactBounds: {
37
- x: number;
38
- y: number;
39
- width: number;
40
- height: number;
41
- }, p1X: number, p1Y: number, p2X: number, p2Y: number): boolean;
42
- _isBoundsEqual(bounds1: {
43
- x: number;
44
- y: number;
45
- width: number;
46
- height: number;
47
- }, bounds2: {
48
- x: number;
49
- y: number;
50
- width: number;
51
- height: number;
52
- }): boolean;
53
- _getAnnotationType(dictionary: _PdfDictionary): _PdfAnnotationType;
54
- _findAnnotation(array: any[]): boolean;
55
- }