@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.
- package/dist/ej2-pdf-data-extract.umd.min.js +1 -1
- package/dist/global/ej2-pdf-data-extract.min.js +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +12 -44
- package/dist/ts/index.d.ts +0 -23
- package/dist/ts/index.ts +0 -23
- package/dist/ts/pdf-data-extract/core/content-parser-helper.d.ts +0 -62
- package/dist/ts/pdf-data-extract/core/content-parser-helper.ts +0 -661
- package/dist/ts/pdf-data-extract/core/enum.d.ts +0 -6
- package/dist/ts/pdf-data-extract/core/enum.ts +0 -6
- package/dist/ts/pdf-data-extract/core/graphic-state.d.ts +0 -33
- package/dist/ts/pdf-data-extract/core/graphic-state.ts +0 -106
- package/dist/ts/pdf-data-extract/core/pdf-data-extractor.d.ts +0 -210
- package/dist/ts/pdf-data-extract/core/pdf-data-extractor.ts +0 -998
- package/dist/ts/pdf-data-extract/core/pdf-text-parser.d.ts +0 -63
- package/dist/ts/pdf-data-extract/core/pdf-text-parser.ts +0 -498
- package/dist/ts/pdf-data-extract/core/redaction/index.d.ts +0 -7
- package/dist/ts/pdf-data-extract/core/redaction/index.ts +0 -7
- package/dist/ts/pdf-data-extract/core/redaction/pdf-path-segment.d.ts +0 -24
- package/dist/ts/pdf-data-extract/core/redaction/pdf-path-segment.ts +0 -59
- package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-processor.d.ts +0 -55
- package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-processor.ts +0 -590
- package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-region.d.ts +0 -281
- package/dist/ts/pdf-data-extract/core/redaction/pdf-redaction-region.ts +0 -342
- package/dist/ts/pdf-data-extract/core/redaction/pdf-redactor.d.ts +0 -172
- package/dist/ts/pdf-data-extract/core/redaction/pdf-redactor.ts +0 -414
- package/dist/ts/pdf-data-extract/core/redaction/pdf-shape-redaction.d.ts +0 -45
- package/dist/ts/pdf-data-extract/core/redaction/pdf-shape-redaction.ts +0 -281
- package/dist/ts/pdf-data-extract/core/redaction/shape-parser-helper.d.ts +0 -32
- package/dist/ts/pdf-data-extract/core/redaction/shape-parser-helper.ts +0 -479
- package/dist/ts/pdf-data-extract/core/redaction/text-glyph-mapper.d.ts +0 -12
- package/dist/ts/pdf-data-extract/core/redaction/text-glyph-mapper.ts +0 -153
- package/dist/ts/pdf-data-extract/core/text-extraction/binary-cmap-reader.d.ts +0 -24
- package/dist/ts/pdf-data-extract/core/text-extraction/binary-cmap-reader.ts +0 -281
- package/dist/ts/pdf-data-extract/core/text-extraction/cmap.d.ts +0 -50
- package/dist/ts/pdf-data-extract/core/text-extraction/cmap.ts +0 -565
- package/dist/ts/pdf-data-extract/core/text-extraction/compact-font-parser.d.ts +0 -191
- package/dist/ts/pdf-data-extract/core/text-extraction/compact-font-parser.ts +0 -1928
- package/dist/ts/pdf-data-extract/core/text-extraction/encoding-utils.d.ts +0 -102
- package/dist/ts/pdf-data-extract/core/text-extraction/encoding-utils.ts +0 -5780
- package/dist/ts/pdf-data-extract/core/text-extraction/font-structure.d.ts +0 -167
- package/dist/ts/pdf-data-extract/core/text-extraction/font-structure.ts +0 -1842
- package/dist/ts/pdf-data-extract/core/text-extraction/font-tables.d.ts +0 -5
- package/dist/ts/pdf-data-extract/core/text-extraction/font-tables.ts +0 -16
- package/dist/ts/pdf-data-extract/core/text-extraction/font-utils.d.ts +0 -18
- package/dist/ts/pdf-data-extract/core/text-extraction/font-utils.ts +0 -630
- package/dist/ts/pdf-data-extract/core/text-extraction/glyph.d.ts +0 -93
- package/dist/ts/pdf-data-extract/core/text-extraction/glyph.ts +0 -622
- package/dist/ts/pdf-data-extract/core/text-extraction/index.d.ts +0 -10
- package/dist/ts/pdf-data-extract/core/text-extraction/index.ts +0 -10
- package/dist/ts/pdf-data-extract/core/text-extraction/matrix-helper.d.ts +0 -38
- package/dist/ts/pdf-data-extract/core/text-extraction/matrix-helper.ts +0 -150
- package/dist/ts/pdf-data-extract/core/text-extraction/metrics.d.ts +0 -16
- package/dist/ts/pdf-data-extract/core/text-extraction/metrics.ts +0 -2938
- package/dist/ts/pdf-data-extract/core/text-structure.d.ts +0 -628
- package/dist/ts/pdf-data-extract/core/text-structure.ts +0 -668
- package/dist/ts/pdf-data-extract/core/utils.d.ts +0 -99
- package/dist/ts/pdf-data-extract/core/utils.ts +0 -626
- package/dist/ts/pdf-data-extract/index.d.ts +0 -23
- package/dist/ts/pdf-data-extract/index.ts +0 -23
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import { Point } from '@syncfusion/ej2-pdf';
|
|
2
|
-
|
|
3
|
-
export class _PdfIntersection {
|
|
4
|
-
_x: number;
|
|
5
|
-
_y: number;
|
|
6
|
-
_toSource: number;
|
|
7
|
-
_toClip: number;
|
|
8
|
-
constructor(s1: _PdfVertex, s2: _PdfVertex, c1: _PdfVertex, c2: _PdfVertex) {
|
|
9
|
-
this._x = 0.0;
|
|
10
|
-
this._y = 0.0;
|
|
11
|
-
this._toSource = 0.0;
|
|
12
|
-
this._toClip = 0.0;
|
|
13
|
-
const d: number =
|
|
14
|
-
(c2._y - c1._y) * (s2._x - s1._x) - (c2._x - c1._x) * (s2._y - s1._y);
|
|
15
|
-
if (d !== 0) {
|
|
16
|
-
this._toSource =
|
|
17
|
-
((c2._x - c1._x) * (s1._y - c1._y) - (c2._y - c1._y) * (s1._x - c1._x)) / d;
|
|
18
|
-
this._toClip =
|
|
19
|
-
((s2._x - s1._x) * (s1._y - c1._y) - (s2._y - s1._y) * (s1._x - c1._x)) / d;
|
|
20
|
-
if (this._isValid()) {
|
|
21
|
-
this._x = s1._x + this._toSource * (s2._x - s1._x);
|
|
22
|
-
this._y = s1._y + this._toSource * (s2._y - s1._y);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
_isValid(): boolean {
|
|
27
|
-
return (
|
|
28
|
-
0 < this._toSource &&
|
|
29
|
-
this._toSource < 1 &&
|
|
30
|
-
0 < this._toClip &&
|
|
31
|
-
this._toClip < 1
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export class _PdfPolygon {
|
|
36
|
-
_first: _PdfVertex;
|
|
37
|
-
private _vertices: number;
|
|
38
|
-
private _lastUnprocessed: _PdfVertex;
|
|
39
|
-
private _firstIntersect: _PdfVertex;
|
|
40
|
-
private _arrayVertices: boolean;
|
|
41
|
-
_globalIntersections: Point[] = [];
|
|
42
|
-
constructor(p: Point[], arrayVertices?: boolean) {
|
|
43
|
-
this._first = null;
|
|
44
|
-
this._vertices = 0;
|
|
45
|
-
this._lastUnprocessed = null;
|
|
46
|
-
this._arrayVertices =
|
|
47
|
-
typeof arrayVertices === 'undefined' ? Array.isArray(p[0]) : arrayVertices;
|
|
48
|
-
p.forEach((point: Point) => {
|
|
49
|
-
this._addVertex(new _PdfVertex(point.x, point.y));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
_addVertex(vertex: _PdfVertex): void {
|
|
53
|
-
if (this._first === null) {
|
|
54
|
-
this._first = vertex;
|
|
55
|
-
this._first._next = vertex;
|
|
56
|
-
this._first._prev = vertex;
|
|
57
|
-
} else {
|
|
58
|
-
const next: _PdfVertex = this._first;
|
|
59
|
-
const prev: _PdfVertex = next._prev;
|
|
60
|
-
next._prev = vertex;
|
|
61
|
-
vertex._next = next;
|
|
62
|
-
vertex._prev = prev;
|
|
63
|
-
if (prev) {
|
|
64
|
-
prev._next = vertex;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
this._vertices++;
|
|
68
|
-
}
|
|
69
|
-
_insertVertex(vertex: _PdfVertex, start: _PdfVertex, end: _PdfVertex): void {
|
|
70
|
-
let curr: _PdfVertex = start;
|
|
71
|
-
while (!curr._equals(end) && curr._distance < vertex._distance) {
|
|
72
|
-
curr = curr._next;
|
|
73
|
-
}
|
|
74
|
-
vertex._next = curr;
|
|
75
|
-
const prev: _PdfVertex = curr._prev;
|
|
76
|
-
vertex._prev = prev;
|
|
77
|
-
if (prev) {
|
|
78
|
-
prev._next = vertex;
|
|
79
|
-
}
|
|
80
|
-
curr._prev = vertex;
|
|
81
|
-
this._vertices++;
|
|
82
|
-
}
|
|
83
|
-
_getNext(v: _PdfVertex): _PdfVertex {
|
|
84
|
-
let c: _PdfVertex = v;
|
|
85
|
-
while (c._isIntersection) {
|
|
86
|
-
c = c._next;
|
|
87
|
-
}
|
|
88
|
-
return c;
|
|
89
|
-
}
|
|
90
|
-
_getFirstIntersect(): _PdfVertex {
|
|
91
|
-
let v: _PdfVertex = this._firstIntersect || this._first;
|
|
92
|
-
do {
|
|
93
|
-
if (v._isIntersection && !v._visited) {
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
v = v._next;
|
|
97
|
-
} while (!v._equals(this._first));
|
|
98
|
-
this._firstIntersect = v;
|
|
99
|
-
return v;
|
|
100
|
-
}
|
|
101
|
-
_hasUnprocessed(): boolean {
|
|
102
|
-
let v: _PdfVertex = this._lastUnprocessed || this._first;
|
|
103
|
-
do {
|
|
104
|
-
if (v._isIntersection && !v._visited) {
|
|
105
|
-
this._lastUnprocessed = v;
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
v = v._next;
|
|
109
|
-
} while (!v._equals(this._first));
|
|
110
|
-
this._lastUnprocessed = null;
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
_getPoints(): Point[] {
|
|
114
|
-
const points: Point[] = [];
|
|
115
|
-
let v: _PdfVertex = this._first;
|
|
116
|
-
do {
|
|
117
|
-
points.push({ x: v._x, y: v._y });
|
|
118
|
-
v = v._next;
|
|
119
|
-
} while (v !== this._first);
|
|
120
|
-
return points;
|
|
121
|
-
}
|
|
122
|
-
_clip(clip: _PdfPolygon, sourceForwards: boolean, clipForwards: boolean): Point[][] {
|
|
123
|
-
this._computeIntersections(clip);
|
|
124
|
-
({ sourceForwards, clipForwards } = this._setEntryExitFlags(clip, sourceForwards, clipForwards));
|
|
125
|
-
const result: Point[][] = this._constructClippedPolygons();
|
|
126
|
-
return result.length > 0 ? result : this._handleEmptyResult(clip);
|
|
127
|
-
}
|
|
128
|
-
private _computeIntersections(clip: _PdfPolygon): void {
|
|
129
|
-
let sourceVertex: _PdfVertex = this._first;
|
|
130
|
-
do {
|
|
131
|
-
if (!sourceVertex._isIntersection) {
|
|
132
|
-
let clipVertex: _PdfVertex = clip._first;
|
|
133
|
-
do {
|
|
134
|
-
if (!clipVertex._isIntersection) {
|
|
135
|
-
const intersection: _PdfIntersection = new _PdfIntersection(
|
|
136
|
-
sourceVertex, this._getNext(sourceVertex._next),
|
|
137
|
-
clipVertex, clip._getNext(clipVertex._next)
|
|
138
|
-
);
|
|
139
|
-
if (intersection._isValid()) {
|
|
140
|
-
const sourceIntersection: _PdfVertex = sourceVertex._createIntersection(intersection._x,
|
|
141
|
-
intersection._y,
|
|
142
|
-
intersection._toSource);
|
|
143
|
-
const clipIntersection: _PdfVertex = clipVertex._createIntersection(intersection._x,
|
|
144
|
-
intersection._y,
|
|
145
|
-
intersection._toClip);
|
|
146
|
-
this._globalIntersections.push({ x: sourceIntersection._x, y: sourceIntersection._y });
|
|
147
|
-
sourceIntersection._corresponding = clipIntersection;
|
|
148
|
-
clipIntersection._corresponding = sourceIntersection;
|
|
149
|
-
this._insertVertex(sourceIntersection, sourceVertex, this._getNext(sourceVertex._next));
|
|
150
|
-
clip._insertVertex(clipIntersection, clipVertex, clip._getNext(clipVertex._next));
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
clipVertex = clipVertex._next;
|
|
154
|
-
} while (!clipVertex._equals(clip._first));
|
|
155
|
-
}
|
|
156
|
-
sourceVertex = sourceVertex._next;
|
|
157
|
-
} while (!sourceVertex._equals(this._first));
|
|
158
|
-
}
|
|
159
|
-
private _setEntryExitFlags(clip: _PdfPolygon, sourceForwards: boolean, clipForwards: boolean):
|
|
160
|
-
{ sourceForwards: boolean, clipForwards: boolean } {
|
|
161
|
-
const sourceInClip: boolean = this._first._isInside(clip);
|
|
162
|
-
const clipInSource: boolean = clip._first._isInside(this);
|
|
163
|
-
sourceForwards = sourceForwards !== sourceInClip;
|
|
164
|
-
clipForwards = clipForwards !== clipInSource;
|
|
165
|
-
let sourceVertex: _PdfVertex = this._first;
|
|
166
|
-
do {
|
|
167
|
-
if (sourceVertex._isIntersection) {
|
|
168
|
-
sourceVertex._isEntry = sourceForwards;
|
|
169
|
-
sourceForwards = !sourceForwards;
|
|
170
|
-
}
|
|
171
|
-
sourceVertex = sourceVertex._next;
|
|
172
|
-
} while (!sourceVertex._equals(this._first));
|
|
173
|
-
let clipVertex: _PdfVertex = clip._first;
|
|
174
|
-
do {
|
|
175
|
-
if (clipVertex._isIntersection) {
|
|
176
|
-
clipVertex._isEntry = clipForwards;
|
|
177
|
-
clipForwards = !clipForwards;
|
|
178
|
-
}
|
|
179
|
-
clipVertex = clipVertex._next;
|
|
180
|
-
} while (!clipVertex._equals(clip._first));
|
|
181
|
-
return { sourceForwards, clipForwards };
|
|
182
|
-
}
|
|
183
|
-
private _constructClippedPolygons(): Point[][] {
|
|
184
|
-
const list: Point[][] = [];
|
|
185
|
-
while (this._hasUnprocessed()) {
|
|
186
|
-
let current: _PdfVertex = this._getFirstIntersect();
|
|
187
|
-
const clipped: _PdfPolygon = new _PdfPolygon([], this._arrayVertices);
|
|
188
|
-
clipped._addVertex(new _PdfVertex(current._x, current._y));
|
|
189
|
-
do {
|
|
190
|
-
current._visit();
|
|
191
|
-
if (current._isEntry) {
|
|
192
|
-
do {
|
|
193
|
-
current = current._next;
|
|
194
|
-
clipped._addVertex(new _PdfVertex(current._x, current._y));
|
|
195
|
-
} while (!current._isIntersection);
|
|
196
|
-
} else {
|
|
197
|
-
do {
|
|
198
|
-
current = current._prev;
|
|
199
|
-
clipped._addVertex(new _PdfVertex(current._x, current._y));
|
|
200
|
-
} while (!current._isIntersection);
|
|
201
|
-
}
|
|
202
|
-
current = current._corresponding;
|
|
203
|
-
} while (!current._visited);
|
|
204
|
-
list.push(clipped._getPoints());
|
|
205
|
-
}
|
|
206
|
-
return list;
|
|
207
|
-
}
|
|
208
|
-
private _handleEmptyResult(clip: _PdfPolygon): Point[][] {
|
|
209
|
-
const sourceInClip: boolean = this._first._isInside(clip);
|
|
210
|
-
const clipInSource: boolean = clip._first._isInside(this);
|
|
211
|
-
if (sourceInClip) {
|
|
212
|
-
return [clip._getPoints(), this._getPoints()];
|
|
213
|
-
} else if (clipInSource) {
|
|
214
|
-
return [this._getPoints(), clip._getPoints()];
|
|
215
|
-
} else {
|
|
216
|
-
return [this._getPoints()];
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
export class _PdfVertex {
|
|
221
|
-
_x: number;
|
|
222
|
-
_y: number;
|
|
223
|
-
_next: _PdfVertex;
|
|
224
|
-
_prev: _PdfVertex;
|
|
225
|
-
_corresponding: _PdfVertex;
|
|
226
|
-
_distance: number;
|
|
227
|
-
_isEntry: boolean;
|
|
228
|
-
_isIntersection: boolean;
|
|
229
|
-
_visited: boolean;
|
|
230
|
-
constructor(x: number, y: number) {
|
|
231
|
-
if (typeof x !== 'number' || typeof y !== 'number') {
|
|
232
|
-
throw new Error('Invalid coordinate input');
|
|
233
|
-
}
|
|
234
|
-
const xCoord: number = x;
|
|
235
|
-
const yCoord: number = y;
|
|
236
|
-
this._x = xCoord;
|
|
237
|
-
this._y = yCoord;
|
|
238
|
-
this._next = null;
|
|
239
|
-
this._prev = null;
|
|
240
|
-
this._corresponding = null;
|
|
241
|
-
this._distance = 0.0;
|
|
242
|
-
this._isEntry = true;
|
|
243
|
-
this._isIntersection = false;
|
|
244
|
-
this._visited = false;
|
|
245
|
-
}
|
|
246
|
-
_createIntersection(x: number, y: number, distance: number): _PdfVertex {
|
|
247
|
-
const vertex: _PdfVertex = new _PdfVertex(x, y);
|
|
248
|
-
vertex._distance = distance;
|
|
249
|
-
vertex._isIntersection = true;
|
|
250
|
-
vertex._isEntry = false;
|
|
251
|
-
return vertex;
|
|
252
|
-
}
|
|
253
|
-
_visit(): void {
|
|
254
|
-
this._visited = true;
|
|
255
|
-
if (this._corresponding !== null && !this._corresponding._visited) {
|
|
256
|
-
this._corresponding._visit();
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
_equals(v: _PdfVertex): boolean {
|
|
260
|
-
return this._x === v._x && this._y === v._y;
|
|
261
|
-
}
|
|
262
|
-
_isInside(poly: _PdfPolygon): boolean {
|
|
263
|
-
let oddNodes: boolean = false;
|
|
264
|
-
let vertex: _PdfVertex = poly._first;
|
|
265
|
-
let next: _PdfVertex = vertex._next;
|
|
266
|
-
const x: number = this._x;
|
|
267
|
-
const y: number = this._y;
|
|
268
|
-
do {
|
|
269
|
-
if (
|
|
270
|
-
((vertex._y < y && next._y >= y) ||
|
|
271
|
-
(next._y < y && vertex._y >= y)) &&
|
|
272
|
-
(vertex._x <= x || next._x <= x)
|
|
273
|
-
) {
|
|
274
|
-
oddNodes = (oddNodes !== (vertex._x + ((y - vertex._y) / (next._y - vertex._y)) * (next._x - vertex._x) < x));
|
|
275
|
-
}
|
|
276
|
-
vertex = vertex._next;
|
|
277
|
-
next = vertex._next || poly._first;
|
|
278
|
-
} while (!vertex._equals(poly._first));
|
|
279
|
-
return oddNodes;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { _PdfContentStream, _PdfRecord, PdfPage, Point } from '@syncfusion/ej2-pdf';
|
|
2
|
-
import { _TextProcessingMode } from '../enum';
|
|
3
|
-
import { PdfRedactor } from './pdf-redactor';
|
|
4
|
-
export declare class _PdfShapeParser {
|
|
5
|
-
private _currentLocation;
|
|
6
|
-
private _pathAccumulator;
|
|
7
|
-
private _clearPathAccumulator;
|
|
8
|
-
_findRedactPath(recordCollection: _PdfRecord[], i: number, page: PdfPage, redaction: PdfRedactor, mode: _TextProcessingMode, stream: _PdfContentStream): number;
|
|
9
|
-
private _flattenIfNeeded;
|
|
10
|
-
private _clipAgainstRedactions;
|
|
11
|
-
private _adjustRedactionBounds;
|
|
12
|
-
private _shouldSkipRendering;
|
|
13
|
-
private _buildRenderingRecords;
|
|
14
|
-
private _getGeometry;
|
|
15
|
-
private _isValidRectangle;
|
|
16
|
-
_processRectangle(recordCollection: _PdfRecord[], i: number, element: string[]): _PdfRecord[];
|
|
17
|
-
private _generateRectanglePath;
|
|
18
|
-
private _rectToPathCommands;
|
|
19
|
-
private _extractPoints;
|
|
20
|
-
private _isIntersecting;
|
|
21
|
-
private _convertPointsToPath;
|
|
22
|
-
private _flattenBezierCurve;
|
|
23
|
-
private _flattenPdfPathCommands;
|
|
24
|
-
private _pointsArraysEqual;
|
|
25
|
-
private _removeDuplicatePoints;
|
|
26
|
-
private _removeRedactionPoints;
|
|
27
|
-
private _buildRecords;
|
|
28
|
-
}
|
|
29
|
-
export declare type _PdfPathCommand = {
|
|
30
|
-
operator: string;
|
|
31
|
-
points: Point[];
|
|
32
|
-
};
|