@syncfusion/ej2-pdf-export 30.2.4 → 31.2.2
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-export.min.js +3 -3
- package/dist/ej2-pdf-export.umd.min.js +3 -3
- package/dist/ej2-pdf-export.umd.min.js.map +1 -1
- package/dist/es6/ej2-pdf-export.es2015.js +142 -23
- package/dist/es6/ej2-pdf-export.es2015.js.map +1 -1
- package/dist/es6/ej2-pdf-export.es5.js +148 -21
- package/dist/es6/ej2-pdf-export.es5.js.map +1 -1
- package/dist/global/ej2-pdf-export.min.js +3 -3
- package/dist/global/ej2-pdf-export.min.js.map +1 -1
- package/dist/global/index.d.ts +2 -2
- package/package.json +2 -2
- package/src/implementation/input-output/pdf-cross-table.js +2 -1
- package/src/implementation/input-output/pdf-writer.d.ts +77 -14
- package/src/implementation/input-output/pdf-writer.js +146 -20
package/dist/global/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* filename: index.d.ts
|
|
3
|
-
* version :
|
|
4
|
-
* Copyright Syncfusion Inc. 2001 -
|
|
3
|
+
* version : 31.2.2
|
|
4
|
+
* Copyright Syncfusion Inc. 2001 - 2025. All rights reserved.
|
|
5
5
|
* Use of this code is subject to the terms of our license.
|
|
6
6
|
* A copy of the current license can be obtained at any time by e-mailing
|
|
7
7
|
* licensing@syncfusion.com. Any infringement will be prosecuted under
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncfusion/ej2-pdf-export",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "31.2.2",
|
|
4
4
|
"description": "Syncfusion TypeScript Component",
|
|
5
5
|
"author": "Syncfusion Inc.",
|
|
6
6
|
"license": "SEE LICENSE IN license",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"es2015": "./dist/es6/ej2-pdf-export.es5.js",
|
|
10
10
|
"devDependencies": {},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@syncfusion/ej2-compression": "~
|
|
12
|
+
"@syncfusion/ej2-compression": "~31.2.2"
|
|
13
13
|
},
|
|
14
14
|
"typings": "index.d.ts",
|
|
15
15
|
"sideEffects": false,
|
|
@@ -171,7 +171,8 @@ var PdfCrossTable = /** @class */ (function () {
|
|
|
171
171
|
*/
|
|
172
172
|
PdfCrossTable.prototype._save = function (writer) {
|
|
173
173
|
this._saveProcess(writer);
|
|
174
|
-
|
|
174
|
+
var helper = writer.stream;
|
|
175
|
+
return helper.buffer.toUint8Array();
|
|
175
176
|
};
|
|
176
177
|
/**
|
|
177
178
|
* `Saves the endess` of the file.
|
|
@@ -4,27 +4,77 @@
|
|
|
4
4
|
import { StreamWriter } from '@syncfusion/ej2-file-utils';
|
|
5
5
|
import { PdfDocumentBase } from './../document/pdf-document-base';
|
|
6
6
|
import { IPdfWriter } from './../../interfaces/i-pdf-writer';
|
|
7
|
-
import { IPdfPrimitive } from './../../interfaces/i-pdf-primitives';
|
|
8
7
|
/**
|
|
9
|
-
*
|
|
8
|
+
* Helper class for chunk buffer.
|
|
10
9
|
* @private
|
|
11
10
|
*/
|
|
12
|
-
export declare class
|
|
11
|
+
export declare class _PdfChunkBuffer {
|
|
12
|
+
/**
|
|
13
|
+
* Specifies the `chunks`.
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
private chunks;
|
|
17
|
+
/**
|
|
18
|
+
* Specifies the `current`.
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
private current;
|
|
22
|
+
/**
|
|
23
|
+
* Specifies the `offset`.
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
private offset;
|
|
27
|
+
/**
|
|
28
|
+
* Specifies the `committed`.
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
private committed;
|
|
32
|
+
/**
|
|
33
|
+
* Specifies the `chunkSize`.
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
private readonly chunkSize;
|
|
37
|
+
/**
|
|
38
|
+
* Initialize an instance of `_PdfChunkBuffer` class.
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
constructor(chunkSize?: number);
|
|
42
|
+
/**
|
|
43
|
+
* Gets the `length`.
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
readonly length: number;
|
|
13
47
|
/**
|
|
14
|
-
*
|
|
48
|
+
* Grows the buffer by allocating a new chunk.
|
|
15
49
|
* @private
|
|
16
50
|
*/
|
|
17
|
-
private
|
|
51
|
+
private grow;
|
|
18
52
|
/**
|
|
19
|
-
*
|
|
53
|
+
* Writes ASCII string as bytes (each charCodeAt masked to 0..255).
|
|
20
54
|
* @private
|
|
21
55
|
*/
|
|
22
|
-
|
|
56
|
+
writeAscii(str: string): void;
|
|
23
57
|
/**
|
|
24
|
-
*
|
|
58
|
+
* Converts to `Uint8Array`.
|
|
25
59
|
* @private
|
|
26
60
|
*/
|
|
27
|
-
|
|
61
|
+
toUint8Array(): Uint8Array;
|
|
62
|
+
/**
|
|
63
|
+
* Destroys the array buffer.
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
destroy(): void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Used to `write a string` into output file.
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
export declare class PdfWriter implements IPdfWriter {
|
|
73
|
+
/**
|
|
74
|
+
* Specifies the `byteCountForStreamWriter`.
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
private byteCountForStreamWriter;
|
|
28
78
|
/**
|
|
29
79
|
* Specifies the parent `document`.
|
|
30
80
|
* @private
|
|
@@ -69,19 +119,23 @@ export declare class PdfWriter implements IPdfWriter {
|
|
|
69
119
|
* `Writes the specified data`.
|
|
70
120
|
* @private
|
|
71
121
|
*/
|
|
72
|
-
write(
|
|
122
|
+
write(data: string | number): void;
|
|
73
123
|
}
|
|
74
124
|
/**
|
|
75
125
|
* Helper class for PDF writer.
|
|
76
126
|
* @private
|
|
77
127
|
*/
|
|
78
128
|
export declare class PdfWriterHelper {
|
|
129
|
+
/**
|
|
130
|
+
* Specifies the `buffer`.
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
79
133
|
buffer: PdfArrayBuffer;
|
|
80
134
|
/**
|
|
81
135
|
* Initialize an instance of `PdfWriterHelper` class.
|
|
82
136
|
* @private
|
|
83
137
|
*/
|
|
84
|
-
constructor();
|
|
138
|
+
constructor(chunkSize?: number);
|
|
85
139
|
/**
|
|
86
140
|
* Writes the specified data.
|
|
87
141
|
* @private
|
|
@@ -98,12 +152,16 @@ export declare class PdfWriterHelper {
|
|
|
98
152
|
* @private
|
|
99
153
|
*/
|
|
100
154
|
export declare class PdfArrayBuffer {
|
|
101
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Specifies the `buffer`.
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
159
|
+
private buf;
|
|
102
160
|
/**
|
|
103
161
|
* Initialize an instance of `PdfArrayBuffer` class.
|
|
104
162
|
* @private
|
|
105
163
|
*/
|
|
106
|
-
constructor();
|
|
164
|
+
constructor(chunkSize?: number);
|
|
107
165
|
/**
|
|
108
166
|
* Gets the `size`.
|
|
109
167
|
* @private
|
|
@@ -115,7 +173,12 @@ export declare class PdfArrayBuffer {
|
|
|
115
173
|
*/
|
|
116
174
|
write(value: string): void;
|
|
117
175
|
/**
|
|
118
|
-
*
|
|
176
|
+
* Converts to `Uint8Array`.
|
|
177
|
+
* @private
|
|
178
|
+
*/
|
|
179
|
+
toUint8Array(): Uint8Array;
|
|
180
|
+
/**
|
|
181
|
+
* Destroys the buffer.
|
|
119
182
|
* @private
|
|
120
183
|
*/
|
|
121
184
|
destroy(): void;
|
|
@@ -1,13 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper class for chunk buffer.
|
|
3
|
+
* @private
|
|
4
|
+
*/
|
|
5
|
+
var _PdfChunkBuffer = /** @class */ (function () {
|
|
6
|
+
/**
|
|
7
|
+
* Initialize an instance of `_PdfChunkBuffer` class.
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
function _PdfChunkBuffer(chunkSize) {
|
|
11
|
+
if (chunkSize === void 0) { chunkSize = 1048576; }
|
|
12
|
+
/**
|
|
13
|
+
* Specifies the `chunks`.
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
this.chunks = [];
|
|
17
|
+
/**
|
|
18
|
+
* Specifies the `offset`.
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
this.offset = 0;
|
|
22
|
+
/**
|
|
23
|
+
* Specifies the `committed`.
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
this.committed = 0;
|
|
27
|
+
this.chunkSize = chunkSize;
|
|
28
|
+
this.current = new Uint8Array(this.chunkSize);
|
|
29
|
+
this.chunks.push(this.current);
|
|
30
|
+
}
|
|
31
|
+
Object.defineProperty(_PdfChunkBuffer.prototype, "length", {
|
|
32
|
+
/**
|
|
33
|
+
* Gets the `length`.
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
get: function () {
|
|
37
|
+
return this.committed + this.offset;
|
|
38
|
+
},
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Grows the buffer by allocating a new chunk.
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
_PdfChunkBuffer.prototype.grow = function () {
|
|
47
|
+
this.committed += this.offset;
|
|
48
|
+
this.current = new Uint8Array(this.chunkSize);
|
|
49
|
+
this.chunks.push(this.current);
|
|
50
|
+
this.offset = 0;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Writes ASCII string as bytes (each charCodeAt masked to 0..255).
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
_PdfChunkBuffer.prototype.writeAscii = function (str) {
|
|
57
|
+
var idx = 0;
|
|
58
|
+
while (idx < str.length) {
|
|
59
|
+
if (this.offset >= this.current.byteLength) {
|
|
60
|
+
this.grow();
|
|
61
|
+
}
|
|
62
|
+
var space = this.current.byteLength - this.offset;
|
|
63
|
+
var toWrite = Math.min(space, str.length - idx);
|
|
64
|
+
for (var i = 0; i < toWrite; i++) {
|
|
65
|
+
this.current[this.offset + i] = str.charCodeAt(idx + i) & 0xFF;
|
|
66
|
+
}
|
|
67
|
+
this.offset += toWrite;
|
|
68
|
+
idx += toWrite;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Converts to `Uint8Array`.
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
_PdfChunkBuffer.prototype.toUint8Array = function () {
|
|
76
|
+
var total = this.length;
|
|
77
|
+
var out = new Uint8Array(total);
|
|
78
|
+
var pos = 0;
|
|
79
|
+
var lastIdx = this.chunks.length - 1;
|
|
80
|
+
for (var i = 0; i <= lastIdx; i++) {
|
|
81
|
+
var chunk = this.chunks[i];
|
|
82
|
+
if (i === lastIdx) {
|
|
83
|
+
out.set(chunk.subarray(0, this.offset), pos);
|
|
84
|
+
pos += this.offset;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
out.set(chunk, pos);
|
|
88
|
+
pos += chunk.byteLength;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Destroys the array buffer.
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
_PdfChunkBuffer.prototype.destroy = function () {
|
|
98
|
+
this.chunks = [];
|
|
99
|
+
this.current = undefined;
|
|
100
|
+
this.offset = 0;
|
|
101
|
+
this.committed = 0;
|
|
102
|
+
};
|
|
103
|
+
return _PdfChunkBuffer;
|
|
104
|
+
}());
|
|
105
|
+
export { _PdfChunkBuffer };
|
|
1
106
|
/**
|
|
2
107
|
* Used to `write a string` into output file.
|
|
3
108
|
* @private
|
|
4
109
|
*/
|
|
5
110
|
var PdfWriter = /** @class */ (function () {
|
|
6
111
|
function PdfWriter(stream) {
|
|
112
|
+
/**
|
|
113
|
+
* Specifies the `byteCountForStreamWriter`.
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
this.byteCountForStreamWriter = 0;
|
|
7
117
|
this.streamWriter = stream;
|
|
8
118
|
}
|
|
9
119
|
Object.defineProperty(PdfWriter.prototype, "document", {
|
|
10
|
-
//properties
|
|
11
120
|
/**
|
|
12
121
|
* Gets and Sets the `document`.
|
|
13
122
|
* @private
|
|
@@ -27,7 +136,11 @@ var PdfWriter = /** @class */ (function () {
|
|
|
27
136
|
* @private
|
|
28
137
|
*/
|
|
29
138
|
get: function () {
|
|
30
|
-
|
|
139
|
+
if (this.streamWriter instanceof PdfWriterHelper) {
|
|
140
|
+
return this.streamWriter.buffer.size;
|
|
141
|
+
}
|
|
142
|
+
// For StreamWriter, we keep an internal count based on written characters
|
|
143
|
+
return this.byteCountForStreamWriter;
|
|
31
144
|
},
|
|
32
145
|
enumerable: true,
|
|
33
146
|
configurable: true
|
|
@@ -38,7 +151,7 @@ var PdfWriter = /** @class */ (function () {
|
|
|
38
151
|
* @private
|
|
39
152
|
*/
|
|
40
153
|
get: function () {
|
|
41
|
-
return this.
|
|
154
|
+
return this.position;
|
|
42
155
|
},
|
|
43
156
|
enumerable: true,
|
|
44
157
|
configurable: true
|
|
@@ -54,15 +167,21 @@ var PdfWriter = /** @class */ (function () {
|
|
|
54
167
|
enumerable: true,
|
|
55
168
|
configurable: true
|
|
56
169
|
});
|
|
57
|
-
//public Methods
|
|
58
170
|
/**
|
|
59
171
|
* `Writes the specified data`.
|
|
60
172
|
* @private
|
|
61
173
|
*/
|
|
62
|
-
PdfWriter.prototype.write = function (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
174
|
+
PdfWriter.prototype.write = function (data) {
|
|
175
|
+
if (typeof data === 'number') {
|
|
176
|
+
data = String.fromCharCode(data);
|
|
177
|
+
}
|
|
178
|
+
if (this.streamWriter instanceof PdfWriterHelper) {
|
|
179
|
+
this.streamWriter.write(data);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
this.streamWriter.write(data);
|
|
183
|
+
this.byteCountForStreamWriter += data.length;
|
|
184
|
+
}
|
|
66
185
|
};
|
|
67
186
|
return PdfWriter;
|
|
68
187
|
}());
|
|
@@ -76,8 +195,9 @@ var PdfWriterHelper = /** @class */ (function () {
|
|
|
76
195
|
* Initialize an instance of `PdfWriterHelper` class.
|
|
77
196
|
* @private
|
|
78
197
|
*/
|
|
79
|
-
function PdfWriterHelper() {
|
|
80
|
-
|
|
198
|
+
function PdfWriterHelper(chunkSize) {
|
|
199
|
+
if (chunkSize === void 0) { chunkSize = 1048576; }
|
|
200
|
+
this.buffer = new PdfArrayBuffer(chunkSize);
|
|
81
201
|
}
|
|
82
202
|
/**
|
|
83
203
|
* Writes the specified data.
|
|
@@ -108,8 +228,9 @@ var PdfArrayBuffer = /** @class */ (function () {
|
|
|
108
228
|
* Initialize an instance of `PdfArrayBuffer` class.
|
|
109
229
|
* @private
|
|
110
230
|
*/
|
|
111
|
-
function PdfArrayBuffer() {
|
|
112
|
-
|
|
231
|
+
function PdfArrayBuffer(chunkSize) {
|
|
232
|
+
if (chunkSize === void 0) { chunkSize = 1048576; }
|
|
233
|
+
this.buf = new _PdfChunkBuffer(chunkSize);
|
|
113
234
|
}
|
|
114
235
|
Object.defineProperty(PdfArrayBuffer.prototype, "size", {
|
|
115
236
|
/**
|
|
@@ -117,7 +238,7 @@ var PdfArrayBuffer = /** @class */ (function () {
|
|
|
117
238
|
* @private
|
|
118
239
|
*/
|
|
119
240
|
get: function () {
|
|
120
|
-
return this.
|
|
241
|
+
return this.buf.length;
|
|
121
242
|
},
|
|
122
243
|
enumerable: true,
|
|
123
244
|
configurable: true
|
|
@@ -127,18 +248,23 @@ var PdfArrayBuffer = /** @class */ (function () {
|
|
|
127
248
|
* @private
|
|
128
249
|
*/
|
|
129
250
|
PdfArrayBuffer.prototype.write = function (value) {
|
|
130
|
-
|
|
131
|
-
this.buffer.push(value.charCodeAt(i) & 0xff);
|
|
132
|
-
}
|
|
251
|
+
this.buf.writeAscii(value);
|
|
133
252
|
};
|
|
134
253
|
/**
|
|
135
|
-
*
|
|
254
|
+
* Converts to `Uint8Array`.
|
|
255
|
+
* @private
|
|
256
|
+
*/
|
|
257
|
+
PdfArrayBuffer.prototype.toUint8Array = function () {
|
|
258
|
+
return this.buf.toUint8Array();
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Destroys the buffer.
|
|
136
262
|
* @private
|
|
137
263
|
*/
|
|
138
264
|
PdfArrayBuffer.prototype.destroy = function () {
|
|
139
|
-
if (this.
|
|
140
|
-
this.
|
|
141
|
-
this.
|
|
265
|
+
if (this.buf) {
|
|
266
|
+
this.buf.destroy();
|
|
267
|
+
this.buf = undefined;
|
|
142
268
|
}
|
|
143
269
|
};
|
|
144
270
|
return PdfArrayBuffer;
|