@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,565 +0,0 @@
1
- import { _isCommand, _PdfCommand, _PdfDecryptStream, _PdfName } from '@syncfusion/ej2-pdf';
2
- import { _PdfBinaryCharacterMapReader } from './binary-cmap-reader';
3
- import { _getEncodingBase64String } from './font-utils';
4
- import { _PdfLexicalOperator } from '@syncfusion/ej2-pdf';
5
- import { _PdfStream } from '@syncfusion/ej2-pdf';
6
- import { _PdfFlateStream } from '@syncfusion/ej2-pdf';
7
- export class _PdfCharacterMap {
8
- _codeSpaceRanges: any; //eslint-disable-line
9
- _numberOfCodeSpaceRanges: number;
10
- _map: any = []; //eslint-disable-line
11
- _name: string
12
- _vertical: boolean;
13
- _builtInCMap: any; //eslint-disable-line
14
- _useCMap: any; //eslint-disable-line
15
- _maximumMapRange: number = 2 ** 24 - 1;
16
- constructor(builtInCMap: boolean = false) {
17
- this._codeSpaceRanges = [[], [], [], []];
18
- this._numberOfCodeSpaceRanges = 0;
19
- this._map = [];
20
- this._name = '';
21
- this._vertical = false;
22
- this._useCMap = null;
23
- this._builtInCMap = builtInCMap;
24
- }
25
- _forEach(callback: any) { //eslint-disable-line
26
- const map: any = this._map; //eslint-disable-line
27
- const length: number = map.length;
28
- if (length <= 0x10000) {
29
- for (let i: number = 0; i < length; i++) {
30
- if (typeof(map[Number.parseInt(i.toString(), 10)]) !== 'undefined') {
31
- callback (i, map[Number.parseInt(i.toString(), 10)]);
32
- }
33
- }
34
- } else {
35
- let keys: any = Object.keys(map); //eslint-disable-line
36
- for (let k: number = 0; k < keys.length; k++) {
37
- const i: any = keys[Number.parseInt(k.toString(), 10)]; //eslint-disable-line
38
- callback(i, map[Number.parseInt(i.toString(), 10)]);
39
- }
40
- }
41
- }
42
- _insertCodeSpaceRange(number: number, low: number, high: number): void {
43
- this._codeSpaceRanges[number - 1].push(low, high);
44
- this._numberOfCodeSpaceRanges++;
45
- }
46
- _mapRangeToDestination(low: number, high: number, destinationLow: any): void { //eslint-disable-line
47
- if (high - low > this._maximumMapRange) {
48
- throw new Error('mapBfRange - ignoring data above _maximumMapRange.');
49
- }
50
- const lastByte: number = destinationLow.length - 1;
51
- while (low <= high) {
52
- this._map[low++] = destinationLow;
53
- const nextCharCode: number = destinationLow.charCodeAt(lastByte) + 1;
54
- if (nextCharCode > 0xff) {
55
- destinationLow = destinationLow.substring(0, lastByte - 1) + String.fromCharCode(destinationLow.charCodeAt(lastByte - 1) + 1) + '\x00';
56
- continue;
57
- }
58
- destinationLow = destinationLow.substring(0, lastByte) + String.fromCharCode(nextCharCode);
59
- }
60
- }
61
- _mapRangeToArray(low: number, high: number, array: any): void { //eslint-disable-line
62
- if (high - low > this._maximumMapRange) {
63
- throw new Error('mapBfRangeToArray - ignoring data above _maximumMapRange.');
64
- }
65
- const ii: number = array.length;
66
- let i: number = 0;
67
- while (low <= high && i < ii) {
68
- this._map[Number.parseInt(low.toString(), 10)] = array[i++];
69
- ++low;
70
- }
71
- }
72
- _mapOne(source: any, destination: any): void { //eslint-disable-line
73
- this._map[Number.parseInt(source.toString(), 10)] = destination;
74
- }
75
- _lookup(code: any): void { //eslint-disable-line
76
- return this._map[Number.parseInt(code.toString(), 10)];
77
- }
78
- _contains(code: any): any { //eslint-disable-line
79
- return this._map[Number.parseInt(code.toString(), 10)] !== undefined;
80
- }
81
- _mapCharacterIdentifierRange(low: number, high: number, destinationLow: number): void {
82
- if (high - low > this._maximumMapRange) {
83
- throw new Error('mapCidRange - ignoring data above _maximumMapRange.');
84
- }
85
- while (low <= high) {
86
- this._map[low++] = destinationLow++;
87
- }
88
- }
89
- _readCharacterCodeFromString(text: any, offset: any, out: any): void { //eslint-disable-line
90
- let c: number = 0;
91
- const codespaceRanges: any = this._codeSpaceRanges; //eslint-disable-line
92
- for (let n: number = 0, nn: number = codespaceRanges.length; n < nn; n++) {
93
- c = ((c << 8) | text.charCodeAt(offset + n)) >>> 0;
94
- const codespaceRange: any = codespaceRanges[n]; //eslint-disable-line
95
- for (let k: number = 0, kk: number = codespaceRange.length; k < kk; ) {
96
- const low: number = codespaceRange[k++];
97
- const high: number = codespaceRange[k++];
98
- if (c >= low && c <= high) {
99
- out.charcode = c;
100
- out.length = n + 1;
101
- return;
102
- }
103
- }
104
- }
105
- out.charcode = 0;
106
- out.length = 1;
107
- }
108
- }
109
- export class _PdfCharacterMapFactory {
110
- _cmapCompressionType: any = { //eslint-disable-line
111
- NONE: 0,
112
- BINARY: 1
113
- };
114
- _builtInCharacterMap: any = [ //eslint-disable-line
115
- 'Adobe-GB1-UCS2',
116
- 'Adobe-CNS1-UCS2',
117
- 'Adobe-Japan1-UCS2',
118
- 'Adobe-Korea1-UCS2',
119
- '78-EUC-H',
120
- '78-EUC-V',
121
- '78-H',
122
- '78-RKSJ-H',
123
- '78-RKSJ-V',
124
- '78-V',
125
- '78ms-RKSJ-H',
126
- '78ms-RKSJ-V',
127
- '83pv-RKSJ-H',
128
- '90ms-RKSJ-H',
129
- '90ms-RKSJ-V',
130
- '90msp-RKSJ-H',
131
- '90msp-RKSJ-V',
132
- '90pv-RKSJ-H',
133
- '90pv-RKSJ-V',
134
- 'Add-H',
135
- 'Add-RKSJ-H',
136
- 'Add-RKSJ-V',
137
- 'Add-V',
138
- 'Adobe-CNS1-0',
139
- 'Adobe-CNS1-1',
140
- 'Adobe-CNS1-2',
141
- 'Adobe-CNS1-3',
142
- 'Adobe-CNS1-4',
143
- 'Adobe-CNS1-5',
144
- 'Adobe-CNS1-6',
145
- 'Adobe-GB1-0',
146
- 'Adobe-GB1-1',
147
- 'Adobe-GB1-2',
148
- 'Adobe-GB1-3',
149
- 'Adobe-GB1-4',
150
- 'Adobe-GB1-5',
151
- 'Adobe-Japan1-0',
152
- 'Adobe-Japan1-1',
153
- 'Adobe-Japan1-2',
154
- 'Adobe-Japan1-3',
155
- 'Adobe-Japan1-4',
156
- 'Adobe-Japan1-5',
157
- 'Adobe-Japan1-6',
158
- 'Adobe-Korea1-0',
159
- 'Adobe-Korea1-1',
160
- 'Adobe-Korea1-2',
161
- 'B5-H',
162
- 'B5-V',
163
- 'B5pc-H',
164
- 'B5pc-V',
165
- 'CNS-EUC-H',
166
- 'CNS-EUC-V',
167
- 'CNS1-H',
168
- 'CNS1-V',
169
- 'CNS2-H',
170
- 'CNS2-V',
171
- 'ETHK-B5-H',
172
- 'ETHK-B5-V',
173
- 'ETen-B5-H',
174
- 'ETen-B5-V',
175
- 'ETenms-B5-H',
176
- 'ETenms-B5-V',
177
- 'EUC-H',
178
- 'EUC-V',
179
- 'Ext-H',
180
- 'Ext-RKSJ-H',
181
- 'Ext-RKSJ-V',
182
- 'Ext-V',
183
- 'GB-EUC-H',
184
- 'GB-EUC-V',
185
- 'GB-H',
186
- 'GB-V',
187
- 'GBK-EUC-H',
188
- 'GBK-EUC-V',
189
- 'GBK2K-H',
190
- 'GBK2K-V',
191
- 'GBKp-EUC-H',
192
- 'GBKp-EUC-V',
193
- 'GBT-EUC-H',
194
- 'GBT-EUC-V',
195
- 'GBT-H',
196
- 'GBT-V',
197
- 'GBTpc-EUC-H',
198
- 'GBTpc-EUC-V',
199
- 'GBpc-EUC-H',
200
- 'GBpc-EUC-V',
201
- 'H',
202
- 'HKdla-B5-H',
203
- 'HKdla-B5-V',
204
- 'HKdlb-B5-H',
205
- 'HKdlb-B5-V',
206
- 'HKgccs-B5-H',
207
- 'HKgccs-B5-V',
208
- 'HKm314-B5-H',
209
- 'HKm314-B5-V',
210
- 'HKm471-B5-H',
211
- 'HKm471-B5-V',
212
- 'HKscs-B5-H',
213
- 'HKscs-B5-V',
214
- 'Hankaku',
215
- 'Hiragana',
216
- 'KSC-EUC-H',
217
- 'KSC-EUC-V',
218
- 'KSC-H',
219
- 'KSC-Johab-H',
220
- 'KSC-Johab-V',
221
- 'KSC-V',
222
- 'KSCms-UHC-H',
223
- 'KSCms-UHC-HW-H',
224
- 'KSCms-UHC-HW-V',
225
- 'KSCms-UHC-V',
226
- 'KSCpc-EUC-H',
227
- 'KSCpc-EUC-V',
228
- 'Katakana',
229
- 'NWP-H',
230
- 'NWP-V',
231
- 'RKSJ-H',
232
- 'RKSJ-V',
233
- 'Roman',
234
- 'UniCNS-UCS2-H',
235
- 'UniCNS-UCS2-V',
236
- 'UniCNS-UTF16-H',
237
- 'UniCNS-UTF16-V',
238
- 'UniCNS-UTF32-H',
239
- 'UniCNS-UTF32-V',
240
- 'UniCNS-UTF8-H',
241
- 'UniCNS-UTF8-V',
242
- 'UniGB-UCS2-H',
243
- 'UniGB-UCS2-V',
244
- 'UniGB-UTF16-H',
245
- 'UniGB-UTF16-V',
246
- 'UniGB-UTF32-H',
247
- 'UniGB-UTF32-V',
248
- 'UniGB-UTF8-H',
249
- 'UniGB-UTF8-V',
250
- 'UniJIS-UCS2-H',
251
- 'UniJIS-UCS2-HW-H',
252
- 'UniJIS-UCS2-HW-V',
253
- 'UniJIS-UCS2-V',
254
- 'UniJIS-UTF16-H',
255
- 'UniJIS-UTF16-V',
256
- 'UniJIS-UTF32-H',
257
- 'UniJIS-UTF32-V',
258
- 'UniJIS-UTF8-H',
259
- 'UniJIS-UTF8-V',
260
- 'UniJIS2004-UTF16-H',
261
- 'UniJIS2004-UTF16-V',
262
- 'UniJIS2004-UTF32-H',
263
- 'UniJIS2004-UTF32-V',
264
- 'UniJIS2004-UTF8-H',
265
- 'UniJIS2004-UTF8-V',
266
- 'UniJISPro-UCS2-HW-V',
267
- 'UniJISPro-UCS2-V',
268
- 'UniJISPro-UTF8-V',
269
- 'UniJISX0213-UTF32-H',
270
- 'UniJISX0213-UTF32-V',
271
- 'UniJISX02132004-UTF32-H',
272
- 'UniJISX02132004-UTF32-V',
273
- 'UniKS-UCS2-H',
274
- 'UniKS-UCS2-V',
275
- 'UniKS-UTF16-H',
276
- 'UniKS-UTF16-V',
277
- 'UniKS-UTF32-H',
278
- 'UniKS-UTF32-V',
279
- 'UniKS-UTF8-H',
280
- 'UniKS-UTF8-V',
281
- 'V',
282
- 'WP-Symbol'
283
- ];
284
- eof: string = 'EOF';
285
- _create(encoding: any, fetchBuiltInCharacterMap: any, _useCharacterMap: any): any { //eslint-disable-line
286
- let parsedCharacterMap: any; //eslint-disable-line
287
- if (encoding instanceof _PdfName) {
288
- return this._createBuiltInCharacterMap(encoding.name, fetchBuiltInCharacterMap);
289
- } else if (encoding instanceof _PdfFlateStream) {
290
- const stream: any = encoding.stream; //eslint-disable-line
291
- if (stream instanceof _PdfStream || stream instanceof _PdfDecryptStream) {
292
- parsedCharacterMap = this._parseCharacterMap(new _PdfCharacterMap(), new _PdfLexicalOperator(encoding),
293
- fetchBuiltInCharacterMap, _useCharacterMap);
294
- }
295
- return parsedCharacterMap;
296
- } else if (encoding instanceof _PdfStream) {
297
- parsedCharacterMap = this._parseCharacterMap(new _PdfCharacterMap(), new _PdfLexicalOperator(encoding),
298
- fetchBuiltInCharacterMap, _useCharacterMap);
299
- return parsedCharacterMap;
300
- }
301
- }
302
- _createBuiltInCharacterMap(name: string, fetchBuiltInCharacterMap: any): any { //eslint-disable-line
303
- if (name === 'Identity-H') {
304
- return new _PdfIdentityCharacterMap(false, 2);
305
- } else if (name === 'Identity-V') {
306
- return new _PdfIdentityCharacterMap(true, 2);
307
- }
308
- if (!this._builtInCharacterMap.includes(name)) {
309
- throw new Error('Unknown CMap name: ' + name);
310
- }
311
- const characterMapData: any = this._fetchCharacterMap(name); //eslint-disable-line
312
- const cMap: _PdfCharacterMap = new _PdfCharacterMap(true);
313
- if (characterMapData.isCompressed) {
314
- return new _PdfBinaryCharacterMapReader()._process(characterMapData.uint8Array, cMap, (useCMap: any) => //eslint-disable-line
315
- this._extendCMap(cMap, fetchBuiltInCharacterMap, useCMap)
316
- );
317
- }
318
- //throw new Error(`Invalid CMap 'compressionType' value: ${compressionType}`);
319
- }
320
- _fetchCharacterMap(name: string): any { //eslint-disable-line
321
- const base64String: string = _getEncodingBase64String(name).replace(/^data:.+;base64,/, '');
322
- const uint8Array: Uint8Array = this._base64ToUnSigned8Array(base64String);
323
- const isCompressed: boolean = true;
324
- const data: any = {uint8Array, isCompressed}; //eslint-disable-line
325
- return data;
326
- }
327
- _base64ToUnSigned8Array(base64String: string): Uint8Array {
328
- const binaryString: string = atob(base64String);
329
- const uint8Array: Uint8Array = new Uint8Array(binaryString.length);
330
- for (let i: number = 0; i < binaryString.length; i++) {
331
- uint8Array[Number.parseInt(i.toString(), 10)] = binaryString.charCodeAt(i);
332
- }
333
- return uint8Array;
334
- }
335
- _parseCharacterMap(characterMap: any, lexer: _PdfLexicalOperator, fetchBuiltInCMap: any, _useCharacterMap: any): any { //eslint-disable-line
336
- let previous: any; //eslint-disable-line
337
- let embeddedUseCMap: any; //eslint-disable-line
338
- while (true) { //eslint-disable-line
339
- try {
340
- const obj: any = lexer.getObject(); //eslint-disable-line
341
- if (obj === this.eof) {
342
- break;
343
- } else if (obj instanceof _PdfName) {
344
- if (obj.name === 'WMode') {
345
- this._parseWritingMode(characterMap, lexer);
346
- } else if (obj.name === 'CMapName') {
347
- this._parseCharacterMapName(characterMap, lexer);
348
- }
349
- previous = obj;
350
- } else if (obj instanceof _PdfCommand) {
351
- switch (obj.command) {
352
- case 'endcmap':
353
- break;
354
- case 'usecmap':
355
- if (previous instanceof _PdfName) {
356
- embeddedUseCMap = previous.name;
357
- }
358
- break;
359
- case 'begincodespacerange':
360
- this._parseCodeSpaceRange(characterMap, lexer);
361
- break;
362
- case 'beginbfchar':
363
- this._parseBaseFontCharacter(characterMap, lexer);
364
- break;
365
- case 'begincidchar':
366
- this._processCharacterMapping(characterMap, lexer);
367
- break;
368
- case 'beginbfrange':
369
- this._mapBaseFontRange(characterMap, lexer);
370
- break;
371
- case 'begincidrange':
372
- this._parseCharacterIdentifierRange(characterMap, lexer);
373
- break;
374
- }
375
- }
376
- } catch (ex) {
377
- continue;
378
- }
379
- }
380
- if (!_useCharacterMap && embeddedUseCMap) {
381
- _useCharacterMap = embeddedUseCMap;
382
- }
383
- if (_useCharacterMap) {
384
- return this._extendCMap(characterMap, fetchBuiltInCMap, _useCharacterMap);
385
- }
386
- return characterMap;
387
- }
388
- _stringToInt(text: string): number {
389
- let a: number = 0;
390
- for (let i: number = 0; i < text.length; i++) {
391
- a = (a << 8) | text.charCodeAt(i);
392
- }
393
- return a >>> 0;
394
- }
395
- _validateString(object: any): void { //eslint-disable-line
396
- if (typeof object !== 'string') {
397
- throw new Error('Malformed CMap: expected string.');
398
- }
399
- }
400
- _expectInt(object: any): void { //eslint-disable-line
401
- if (!Number.isInteger(object)) {
402
- throw new Error('Malformed CMap: expected int.');
403
- }
404
- }
405
- _parseBaseFontCharacter(characterMap: any, lexer: _PdfLexicalOperator): void { //eslint-disable-line
406
- while (true) { // eslint-disable-line
407
- let obj: any = lexer.getObject(); //eslint-disable-line
408
- if (obj === this.eof) {
409
- break;
410
- }
411
- if (_isCommand(obj, 'endbfchar')) {
412
- return;
413
- }
414
- this._validateString(obj);
415
- const source: number = this._stringToInt(obj);
416
- obj = lexer.getObject();
417
- this._validateString(obj);
418
- const destination: any = obj; //eslint-disable-line
419
- characterMap._mapOne(source, destination);
420
- }
421
- }
422
- _mapBaseFontRange(cMap: _PdfCharacterMap, lexer: _PdfLexicalOperator): void {
423
- while (true) { // eslint-disable-line
424
- let obj: any = lexer.getObject(); //eslint-disable-line
425
- if (obj === this.eof) {
426
- break;
427
- }
428
- if (_isCommand(obj, 'endbfrange')) {
429
- return;
430
- }
431
- this._validateString(obj);
432
- const low: number = this._stringToInt(obj);
433
- obj = lexer.getObject();
434
- this._validateString(obj);
435
- const high: number = this._stringToInt(obj);
436
- obj = lexer.getObject();
437
- if (Number.isInteger(obj) || typeof obj === 'string') {
438
- const dstLow: any = Number.isInteger(obj) ? String.fromCharCode(obj) : obj; //eslint-disable-line
439
- cMap._mapRangeToDestination(low, high, dstLow);
440
- } else if (_isCommand(obj, '[')) {
441
- obj = lexer.getObject();
442
- const array: any[] = []; //eslint-disable-line
443
- while (!_isCommand(obj, ']') && obj !== this.eof) {
444
- array.push(obj);
445
- obj = lexer.getObject();
446
- }
447
- cMap._mapRangeToArray(low, high, array);
448
- } else {
449
- break;
450
- }
451
- }
452
- }
453
- _processCharacterMapping(characterMap: any, lexer: _PdfLexicalOperator): void { //eslint-disable-line
454
- while (true) { // eslint-disable-line
455
- let obj: any = lexer.getObject(); //eslint-disable-line
456
- if (obj === this.eof) {
457
- break;
458
- }
459
- if (_isCommand(obj, 'endcidchar')) {
460
- return;
461
- }
462
- this._validateString(obj);
463
- const src: number = this._stringToInt(obj);
464
- obj = lexer.getObject();
465
- this._expectInt(obj);
466
- const dst: any = obj; //eslint-disable-line
467
- characterMap._mapOne(src, dst);
468
- }
469
- }
470
- _parseCharacterIdentifierRange(characterMap: any, lexer: any): any { // eslint-disable-line
471
- while (true) { // eslint-disable-line
472
- let obj: any = lexer.getObj(); //eslint-disable-line
473
- if (obj === this.eof) {
474
- break;
475
- }
476
- if (_isCommand(obj, 'endcidrange')) {
477
- return;
478
- }
479
- this._validateString(obj);
480
- const low: number = this._stringToInt(obj);
481
- obj = lexer.getObj();
482
- this._validateString(obj);
483
- const high: number = this._stringToInt(obj);
484
- obj = lexer.getObj();
485
- this._expectInt(obj);
486
- const dstLow: any = obj; // eslint-disable-line
487
- characterMap._mapCharacterIdentifierRange(low, high, dstLow);
488
- }
489
- }
490
- _parseCodeSpaceRange(characterMap: _PdfCharacterMap, lexer: _PdfLexicalOperator): void {
491
- while (true) { // eslint-disable-line
492
- let obj: any = lexer.getObject(); //eslint-disable-line
493
- if (obj === this.eof) {
494
- break;
495
- }
496
- if (_isCommand(obj, 'endcodespacerange')) {
497
- return;
498
- }
499
- if (typeof obj !== 'string') {
500
- break;
501
- }
502
- const low: number = this._stringToInt(obj);
503
- obj = lexer.getObject();
504
- if (typeof obj !== 'string') {
505
- break;
506
- }
507
- const high: number = this._stringToInt(obj);
508
- characterMap._insertCodeSpaceRange(obj.length, low, high);
509
- }
510
- }
511
- _parseWritingMode(cMap: any, lexer: _PdfLexicalOperator): void { //eslint-disable-line
512
- const obj: any = lexer.getObject(); //eslint-disable-line
513
- if (Number.isInteger(obj)) {
514
- cMap.vertical = obj;
515
- }
516
- }
517
- _parseCharacterMapName(characterMap:any, lexer: _PdfLexicalOperator): void { //eslint-disable-line
518
- const obj: any = lexer.getObject(); //eslint-disable-line
519
- if (obj instanceof _PdfName) {
520
- characterMap.name = obj.name;
521
- }
522
- }
523
- _extendCMap(characterMap: any, fetchBuiltInCMap: any, _useCharacterMap: any): any { //eslint-disable-line
524
- characterMap.useCMap = this._createBuiltInCharacterMap(_useCharacterMap, fetchBuiltInCMap);
525
- if (characterMap.numCodespaceRanges === 0) {
526
- const useCodespaceRanges: any = characterMap.useCMap.codespaceRanges; // eslint-disable-line
527
- for (let i: number = 0; i < useCodespaceRanges.length; i++) {
528
- characterMap.codespaceRanges[Number.parseInt(i.toString(), 10)] = useCodespaceRanges[Number.parseInt(i.toString(), 10)].
529
- slice();
530
- }
531
- characterMap.numCodespaceRanges = characterMap.useCMap.numCodespaceRanges;
532
- }
533
- characterMap.useCMap.forEach((key: any, value: any) => { //eslint-disable-line
534
- if (!characterMap._contains(key)) {
535
- characterMap._mapOne(key, characterMap.useCMap.lookup(key));
536
- }
537
- });
538
- return characterMap;
539
- }
540
- }
541
- export class _PdfIdentityCharacterMap extends _PdfCharacterMap {
542
- constructor(vertical: boolean, count: any) { //eslint-disable-line
543
- super();
544
- this._vertical = vertical;
545
- this._insertCodeSpaceRange(count, 0, 0xffff);
546
- }
547
- _insertCodeSpaceRange(count: number, low: number, high: number): void {
548
- this._codeSpaceRanges[count - 1].push(low, high);
549
- this._numberOfCodeSpaceRanges++;
550
- }
551
- _lookup(code: any): any { //eslint-disable-line
552
- return Number.isInteger(code) && code <= 0xffff ? code : undefined;
553
- }
554
- _contains(code: any): boolean{ //eslint-disable-line
555
- return Number.isInteger(code) && code <= 0xffff;
556
- }
557
- _charCodeOf(value: any): any { //eslint-disable-line
558
- return Number.isInteger(value) && value <= 0xffff ? value : -1;
559
- }
560
- _forEach(callback: any) { //eslint-disable-line
561
- for (let i: number = 0; i <= 0xffff; i++) {
562
- callback(i, i);
563
- }
564
- }
565
- }