@syncfusion/ej2-pdf-data-extract 31.1.17 → 31.1.19

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