| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286 |
1×
1×
1×
1×
1×
1×
1×
93×
93×
93×
1×
1×
1×
1×
104×
104×
1×
1×
1×
1×
1×
1×
1×
12×
12×
12×
1×
1×
1×
1×
1×
1×
1×
1×
2×
2×
2×
2×
2×
1×
7×
1×
1×
1×
1×
1×
1×
87×
87×
87×
87×
82×
5×
87×
87×
87×
87×
1×
156294×
77091×
1×
6×
1×
1×
77003×
53×
76950×
1×
14×
14×
14×
14×
2×
12×
12×
7×
12×
12×
1×
1×
5×
1×
5×
1×
27×
27×
1×
1×
1×
1×
1×
1×
1×
1×
1×
10×
10×
10×
10×
10×
10×
1×
1×
274×
274×
274×
1916×
274×
1×
3×
3×
3×
3×
3×
3×
3×
3×
1×
1×
1×
1×
1×
1×
1×
| /* istanbul ignore next */
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
define(["require", "exports", "./pdf-primitives", "./utils"], function (require, exports, pdf_primitives_1, utils_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _PdfBaseStream = (function () {
function _PdfBaseStream() {
this._isCompress = true;
this._isImage = false;
}
_PdfBaseStream.prototype.getByte = function () {
return null;
};
_PdfBaseStream.prototype.getBytes = function (length) {
return null;
};
Object.defineProperty(_PdfBaseStream.prototype, "length", {
get: function () {
throw new Error('Abstract getter `length` accessed');
},
enumerable: true,
configurable: true
});
Object.defineProperty(_PdfBaseStream.prototype, "isEmpty", {
get: function () {
throw new Error('Abstract getter `isEmpty` accessed');
},
enumerable: true,
configurable: true
});
Object.defineProperty(_PdfBaseStream.prototype, "isDataLoaded", {
get: function () {
return true;
},
enumerable: true,
configurable: true
});
_PdfBaseStream.prototype.peekByte = function () {
var peekedByte = this.getByte();
if (peekedByte !== -1) {
this.offset--;
}
return peekedByte;
};
_PdfBaseStream.prototype.peekBytes = function (length) {
var bytes = this.getBytes(length);
this.offset -= bytes.length;
return bytes;
};
_PdfBaseStream.prototype.getUnsignedInteger16 = function () {
var b0 = this.getByte();
var b1 = this.getByte();
if (b0 === -1 || b1 === -1) {
return -1;
}
return (b0 << 8) + b1;
};
_PdfBaseStream.prototype.getInt32 = function () {
var b0 = this.getByte();
var b1 = this.getByte();
var b2 = this.getByte();
var b3 = this.getByte();
return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
};
_PdfBaseStream.prototype.getByteRange = function (begin, end) {
return null;
};
_PdfBaseStream.prototype.makeSubStream = function (start, length, dictionary) {
return null;
};
_PdfBaseStream.prototype.readBlock = function () {
return null;
};
_PdfBaseStream.prototype.reset = function () {
return null;
};
_PdfBaseStream.prototype.moveStart = function () {
return null;
};
_PdfBaseStream.prototype.getString = function (isHex, bytes) {
Eif (isHex === void 0) { isHex = false; }
Eif (typeof bytes === 'undefined' || bytes === null) {
bytes = this.getBytes();
}
Iif (isHex) {
return utils_1._byteArrayToHexString(bytes);
}
else {
return utils_1._bytesToString(bytes);
}
};
_PdfBaseStream.prototype.skip = function (n) {
this.offset += n || 1;
};
_PdfBaseStream.prototype.getBaseStreams = function () {
return null;
};
return _PdfBaseStream;
}());
exports._PdfBaseStream = _PdfBaseStream;
var _PdfStream = (function (_super) {
__extends(_PdfStream, _super);
function _PdfStream(arrayBuffer, dictionary, start, length) {
var _this = _super.call(this) || this;
_this.isImageStream = false;
_this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
if (typeof start !== 'undefined') {
_this.start = start;
}
else {
_this.start = 0;
}
_this.position = _this.start;
_this.end = start + length || _this.bytes.length;
_this.dictionary = dictionary;
return _this;
}
Object.defineProperty(_PdfStream.prototype, "position", {
get: function () {
return this.offset;
},
set: function (value) {
this.offset = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(_PdfStream.prototype, "length", {
get: function () {
return this.end - this.start;
},
enumerable: true,
configurable: true
});
Object.defineProperty(_PdfStream.prototype, "isEmpty", {
get: function () {
return this.length === 0;
},
enumerable: true,
configurable: true
});
_PdfStream.prototype.getByte = function () {
if (this.position >= this.end) {
return -1;
}
return this.bytes[this.position++];
};
_PdfStream.prototype.getBytes = function (length) {
var bytes = this.bytes;
var position = this.position;
var strEnd = this.end;
if (!length) {
return bytes.subarray(position, strEnd);
}
var end = position + length;
if (end > strEnd) {
end = strEnd;
}
this.position = end;
return bytes.subarray(position, end);
};
_PdfStream.prototype.getByteRange = function (begin, end) {
if (begin < 0) {
begin = 0;
}
if (end > this.end) {
end = this.end;
}
return this.bytes.subarray(begin, end);
};
_PdfStream.prototype.reset = function () {
this.position = this.start;
};
_PdfStream.prototype.moveStart = function () {
this.start = this.position;
};
_PdfStream.prototype.makeSubStream = function (start, length, dictionary) {
if (dictionary === void 0) { dictionary = null; }
return new _PdfStream(this.bytes.buffer, dictionary, start, length);
};
_PdfStream.prototype.readBlock = function () {
throw new Error('Abstract method `readBlock` called');
};
_PdfStream.prototype._clearStream = function () {
if (this.dictionary !== null && typeof this.dictionary !== 'undefined' && this.dictionary.has('Filter')) {
delete this.dictionary._map.Filter;
}
this._isCompress = true;
this.dictionary._updated = true;
};
_PdfStream.prototype._write = function (text) {
this.bytes = new Uint8Array(text.length);
for (var i = 0; i < text.length; i++) {
this.bytes[i] = text.charCodeAt(i);
}
this.end = this.bytes.length;
this.dictionary._updated = true;
};
_PdfStream.prototype._writeBytes = function (data) {
this.bytes = new Uint8Array(data);
this.end = this.bytes.length;
this.dictionary._updated = true;
};
return _PdfStream;
}(_PdfBaseStream));
exports._PdfStream = _PdfStream;
var _PdfContentStream = (function (_super) {
__extends(_PdfContentStream, _super);
function _PdfContentStream(bytes) {
var _this = _super.call(this) || this;
Eif (utils_1._isNullOrUndefined(bytes)) {
_this._bytes = bytes;
}
else {
_this._bytes = [];
}
_this.dictionary = new pdf_primitives_1._PdfDictionary();
_this.dictionary._updated = true;
return _this;
}
Object.defineProperty(_PdfContentStream.prototype, "length", {
get: function () {
return this._bytes.length;
},
enumerable: true,
configurable: true
});
_PdfContentStream.prototype.write = function (data) {
var _a;
Eif (typeof data === 'string') {
for (var i = 0; i < data.length; i++) {
this._bytes.push(data.charCodeAt(i));
}
}
else {
(_a = this._bytes).push.apply(_a, data);
}
this.dictionary._updated = true;
};
_PdfContentStream.prototype.getString = function (isHex) {
Eif (isHex === void 0) { isHex = false; }
var bytes = new Uint8Array(this._bytes);
Iif (typeof bytes === 'undefined' || bytes === null || typeof bytes.length === 'undefined') {
throw new Error('Invalid argument for bytesToString');
}
Iif (isHex) {
return utils_1._byteArrayToHexString(bytes);
}
else {
var len = bytes.length;
var max = 8192;
Eif (len < max) {
return String.fromCharCode.apply(null, bytes);
}
var stringBuffer = [];
for (var i = 0; i < len; i += max) {
stringBuffer.push(String.fromCharCode.apply(null, bytes.subarray(i, Math.min(i + max, len))));
}
return stringBuffer.join('');
}
};
return _PdfContentStream;
}(_PdfBaseStream));
exports._PdfContentStream = _PdfContentStream;
var _PdfNullStream = (function (_super) {
__extends(_PdfNullStream, _super);
function _PdfNullStream() {
return _super.call(this, new Uint8Array(0)) || this;
}
return _PdfNullStream;
}(_PdfStream));
exports._PdfNullStream = _PdfNullStream;
});
|