pdfkit 0.8.3 → 0.11.0
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/CHANGELOG.md +39 -0
- package/README.md +121 -111
- package/js/{font/data → data}/Courier-Bold.afm +0 -0
- package/js/{font/data → data}/Courier-BoldOblique.afm +0 -0
- package/js/{font/data → data}/Courier-Oblique.afm +0 -0
- package/js/{font/data → data}/Courier.afm +0 -0
- package/js/{font/data → data}/Helvetica-Bold.afm +0 -0
- package/js/{font/data → data}/Helvetica-BoldOblique.afm +0 -0
- package/js/{font/data → data}/Helvetica-Oblique.afm +0 -0
- package/js/{font/data → data}/Helvetica.afm +0 -0
- package/js/{font/data → data}/Symbol.afm +0 -0
- package/js/{font/data → data}/Times-Bold.afm +0 -0
- package/js/{font/data → data}/Times-BoldItalic.afm +0 -0
- package/js/{font/data → data}/Times-Italic.afm +0 -0
- package/js/{font/data → data}/Times-Roman.afm +0 -0
- package/js/{font/data → data}/ZapfDingbats.afm +0 -0
- package/js/pdfkit.es5.js +6202 -0
- package/js/pdfkit.es5.js.map +1 -0
- package/js/pdfkit.esnext.js +5549 -0
- package/js/pdfkit.esnext.js.map +1 -0
- package/js/pdfkit.js +5581 -0
- package/js/pdfkit.js.map +1 -0
- package/js/pdfkit.standalone.js +65118 -0
- package/js/virtual-fs.js +70 -0
- package/package.json +52 -22
- package/.npmignore +0 -8
- package/Makefile +0 -30
- package/js/data.js +0 -192
- package/js/document.js +0 -247
- package/js/font/afm.js +0 -170
- package/js/font/data/MustRead.html +0 -19
- package/js/font/embedded.js +0 -234
- package/js/font/standard.js +0 -124
- package/js/font.js +0 -75
- package/js/gradient.js +0 -240
- package/js/image/jpeg.js +0 -78
- package/js/image/png.js +0 -158
- package/js/image.js +0 -53
- package/js/line_wrapper.js +0 -252
- package/js/mixins/annotations.js +0 -133
- package/js/mixins/color.js +0 -298
- package/js/mixins/fonts.js +0 -71
- package/js/mixins/images.js +0 -111
- package/js/mixins/text.js +0 -344
- package/js/mixins/vector.js +0 -302
- package/js/object.js +0 -115
- package/js/page.js +0 -170
- package/js/path.js +0 -366
- package/js/reference.js +0 -109
package/js/path.js
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
// Generated by CoffeeScript 1.12.6
|
|
2
|
-
(function() {
|
|
3
|
-
var SVGPath;
|
|
4
|
-
|
|
5
|
-
SVGPath = (function() {
|
|
6
|
-
var apply, arcToSegments, cx, cy, parameters, parse, px, py, runners, segmentToBezier, solveArc, sx, sy;
|
|
7
|
-
|
|
8
|
-
function SVGPath() {}
|
|
9
|
-
|
|
10
|
-
SVGPath.apply = function(doc, path) {
|
|
11
|
-
var commands;
|
|
12
|
-
commands = parse(path);
|
|
13
|
-
return apply(commands, doc);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
parameters = {
|
|
17
|
-
A: 7,
|
|
18
|
-
a: 7,
|
|
19
|
-
C: 6,
|
|
20
|
-
c: 6,
|
|
21
|
-
H: 1,
|
|
22
|
-
h: 1,
|
|
23
|
-
L: 2,
|
|
24
|
-
l: 2,
|
|
25
|
-
M: 2,
|
|
26
|
-
m: 2,
|
|
27
|
-
Q: 4,
|
|
28
|
-
q: 4,
|
|
29
|
-
S: 4,
|
|
30
|
-
s: 4,
|
|
31
|
-
T: 2,
|
|
32
|
-
t: 2,
|
|
33
|
-
V: 1,
|
|
34
|
-
v: 1,
|
|
35
|
-
Z: 0,
|
|
36
|
-
z: 0
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
parse = function(path) {
|
|
40
|
-
var args, c, cmd, curArg, foundDecimal, j, len, params, ret;
|
|
41
|
-
ret = [];
|
|
42
|
-
args = [];
|
|
43
|
-
curArg = "";
|
|
44
|
-
foundDecimal = false;
|
|
45
|
-
params = 0;
|
|
46
|
-
for (j = 0, len = path.length; j < len; j++) {
|
|
47
|
-
c = path[j];
|
|
48
|
-
if (parameters[c] != null) {
|
|
49
|
-
params = parameters[c];
|
|
50
|
-
if (cmd) {
|
|
51
|
-
if (curArg.length > 0) {
|
|
52
|
-
args[args.length] = +curArg;
|
|
53
|
-
}
|
|
54
|
-
ret[ret.length] = {
|
|
55
|
-
cmd: cmd,
|
|
56
|
-
args: args
|
|
57
|
-
};
|
|
58
|
-
args = [];
|
|
59
|
-
curArg = "";
|
|
60
|
-
foundDecimal = false;
|
|
61
|
-
}
|
|
62
|
-
cmd = c;
|
|
63
|
-
} else if ((c === " " || c === ",") || (c === "-" && curArg.length > 0 && curArg[curArg.length - 1] !== 'e') || (c === "." && foundDecimal)) {
|
|
64
|
-
if (curArg.length === 0) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (args.length === params) {
|
|
68
|
-
ret[ret.length] = {
|
|
69
|
-
cmd: cmd,
|
|
70
|
-
args: args
|
|
71
|
-
};
|
|
72
|
-
args = [+curArg];
|
|
73
|
-
if (cmd === "M") {
|
|
74
|
-
cmd = "L";
|
|
75
|
-
}
|
|
76
|
-
if (cmd === "m") {
|
|
77
|
-
cmd = "l";
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
args[args.length] = +curArg;
|
|
81
|
-
}
|
|
82
|
-
foundDecimal = c === ".";
|
|
83
|
-
curArg = c === '-' || c === '.' ? c : '';
|
|
84
|
-
} else {
|
|
85
|
-
curArg += c;
|
|
86
|
-
if (c === '.') {
|
|
87
|
-
foundDecimal = true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (curArg.length > 0) {
|
|
92
|
-
if (args.length === params) {
|
|
93
|
-
ret[ret.length] = {
|
|
94
|
-
cmd: cmd,
|
|
95
|
-
args: args
|
|
96
|
-
};
|
|
97
|
-
args = [+curArg];
|
|
98
|
-
if (cmd === "M") {
|
|
99
|
-
cmd = "L";
|
|
100
|
-
}
|
|
101
|
-
if (cmd === "m") {
|
|
102
|
-
cmd = "l";
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
args[args.length] = +curArg;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
ret[ret.length] = {
|
|
109
|
-
cmd: cmd,
|
|
110
|
-
args: args
|
|
111
|
-
};
|
|
112
|
-
return ret;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
cx = cy = px = py = sx = sy = 0;
|
|
116
|
-
|
|
117
|
-
apply = function(commands, doc) {
|
|
118
|
-
var c, i, j, len, name;
|
|
119
|
-
cx = cy = px = py = sx = sy = 0;
|
|
120
|
-
for (i = j = 0, len = commands.length; j < len; i = ++j) {
|
|
121
|
-
c = commands[i];
|
|
122
|
-
if (typeof runners[name = c.cmd] === "function") {
|
|
123
|
-
runners[name](doc, c.args);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return cx = cy = px = py = 0;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
runners = {
|
|
130
|
-
M: function(doc, a) {
|
|
131
|
-
cx = a[0];
|
|
132
|
-
cy = a[1];
|
|
133
|
-
px = py = null;
|
|
134
|
-
sx = cx;
|
|
135
|
-
sy = cy;
|
|
136
|
-
return doc.moveTo(cx, cy);
|
|
137
|
-
},
|
|
138
|
-
m: function(doc, a) {
|
|
139
|
-
cx += a[0];
|
|
140
|
-
cy += a[1];
|
|
141
|
-
px = py = null;
|
|
142
|
-
sx = cx;
|
|
143
|
-
sy = cy;
|
|
144
|
-
return doc.moveTo(cx, cy);
|
|
145
|
-
},
|
|
146
|
-
C: function(doc, a) {
|
|
147
|
-
cx = a[4];
|
|
148
|
-
cy = a[5];
|
|
149
|
-
px = a[2];
|
|
150
|
-
py = a[3];
|
|
151
|
-
return doc.bezierCurveTo.apply(doc, a);
|
|
152
|
-
},
|
|
153
|
-
c: function(doc, a) {
|
|
154
|
-
doc.bezierCurveTo(a[0] + cx, a[1] + cy, a[2] + cx, a[3] + cy, a[4] + cx, a[5] + cy);
|
|
155
|
-
px = cx + a[2];
|
|
156
|
-
py = cy + a[3];
|
|
157
|
-
cx += a[4];
|
|
158
|
-
return cy += a[5];
|
|
159
|
-
},
|
|
160
|
-
S: function(doc, a) {
|
|
161
|
-
if (px === null) {
|
|
162
|
-
px = cx;
|
|
163
|
-
py = cy;
|
|
164
|
-
}
|
|
165
|
-
doc.bezierCurveTo(cx - (px - cx), cy - (py - cy), a[0], a[1], a[2], a[3]);
|
|
166
|
-
px = a[0];
|
|
167
|
-
py = a[1];
|
|
168
|
-
cx = a[2];
|
|
169
|
-
return cy = a[3];
|
|
170
|
-
},
|
|
171
|
-
s: function(doc, a) {
|
|
172
|
-
if (px === null) {
|
|
173
|
-
px = cx;
|
|
174
|
-
py = cy;
|
|
175
|
-
}
|
|
176
|
-
doc.bezierCurveTo(cx - (px - cx), cy - (py - cy), cx + a[0], cy + a[1], cx + a[2], cy + a[3]);
|
|
177
|
-
px = cx + a[0];
|
|
178
|
-
py = cy + a[1];
|
|
179
|
-
cx += a[2];
|
|
180
|
-
return cy += a[3];
|
|
181
|
-
},
|
|
182
|
-
Q: function(doc, a) {
|
|
183
|
-
px = a[0];
|
|
184
|
-
py = a[1];
|
|
185
|
-
cx = a[2];
|
|
186
|
-
cy = a[3];
|
|
187
|
-
return doc.quadraticCurveTo(a[0], a[1], cx, cy);
|
|
188
|
-
},
|
|
189
|
-
q: function(doc, a) {
|
|
190
|
-
doc.quadraticCurveTo(a[0] + cx, a[1] + cy, a[2] + cx, a[3] + cy);
|
|
191
|
-
px = cx + a[0];
|
|
192
|
-
py = cy + a[1];
|
|
193
|
-
cx += a[2];
|
|
194
|
-
return cy += a[3];
|
|
195
|
-
},
|
|
196
|
-
T: function(doc, a) {
|
|
197
|
-
if (px === null) {
|
|
198
|
-
px = cx;
|
|
199
|
-
py = cy;
|
|
200
|
-
} else {
|
|
201
|
-
px = cx - (px - cx);
|
|
202
|
-
py = cy - (py - cy);
|
|
203
|
-
}
|
|
204
|
-
doc.quadraticCurveTo(px, py, a[0], a[1]);
|
|
205
|
-
px = cx - (px - cx);
|
|
206
|
-
py = cy - (py - cy);
|
|
207
|
-
cx = a[0];
|
|
208
|
-
return cy = a[1];
|
|
209
|
-
},
|
|
210
|
-
t: function(doc, a) {
|
|
211
|
-
if (px === null) {
|
|
212
|
-
px = cx;
|
|
213
|
-
py = cy;
|
|
214
|
-
} else {
|
|
215
|
-
px = cx - (px - cx);
|
|
216
|
-
py = cy - (py - cy);
|
|
217
|
-
}
|
|
218
|
-
doc.quadraticCurveTo(px, py, cx + a[0], cy + a[1]);
|
|
219
|
-
cx += a[0];
|
|
220
|
-
return cy += a[1];
|
|
221
|
-
},
|
|
222
|
-
A: function(doc, a) {
|
|
223
|
-
solveArc(doc, cx, cy, a);
|
|
224
|
-
cx = a[5];
|
|
225
|
-
return cy = a[6];
|
|
226
|
-
},
|
|
227
|
-
a: function(doc, a) {
|
|
228
|
-
a[5] += cx;
|
|
229
|
-
a[6] += cy;
|
|
230
|
-
solveArc(doc, cx, cy, a);
|
|
231
|
-
cx = a[5];
|
|
232
|
-
return cy = a[6];
|
|
233
|
-
},
|
|
234
|
-
L: function(doc, a) {
|
|
235
|
-
cx = a[0];
|
|
236
|
-
cy = a[1];
|
|
237
|
-
px = py = null;
|
|
238
|
-
return doc.lineTo(cx, cy);
|
|
239
|
-
},
|
|
240
|
-
l: function(doc, a) {
|
|
241
|
-
cx += a[0];
|
|
242
|
-
cy += a[1];
|
|
243
|
-
px = py = null;
|
|
244
|
-
return doc.lineTo(cx, cy);
|
|
245
|
-
},
|
|
246
|
-
H: function(doc, a) {
|
|
247
|
-
cx = a[0];
|
|
248
|
-
px = py = null;
|
|
249
|
-
return doc.lineTo(cx, cy);
|
|
250
|
-
},
|
|
251
|
-
h: function(doc, a) {
|
|
252
|
-
cx += a[0];
|
|
253
|
-
px = py = null;
|
|
254
|
-
return doc.lineTo(cx, cy);
|
|
255
|
-
},
|
|
256
|
-
V: function(doc, a) {
|
|
257
|
-
cy = a[0];
|
|
258
|
-
px = py = null;
|
|
259
|
-
return doc.lineTo(cx, cy);
|
|
260
|
-
},
|
|
261
|
-
v: function(doc, a) {
|
|
262
|
-
cy += a[0];
|
|
263
|
-
px = py = null;
|
|
264
|
-
return doc.lineTo(cx, cy);
|
|
265
|
-
},
|
|
266
|
-
Z: function(doc) {
|
|
267
|
-
doc.closePath();
|
|
268
|
-
cx = sx;
|
|
269
|
-
return cy = sy;
|
|
270
|
-
},
|
|
271
|
-
z: function(doc) {
|
|
272
|
-
doc.closePath();
|
|
273
|
-
cx = sx;
|
|
274
|
-
return cy = sy;
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
solveArc = function(doc, x, y, coords) {
|
|
279
|
-
var bez, ex, ey, j, large, len, results, rot, rx, ry, seg, segs, sweep;
|
|
280
|
-
rx = coords[0], ry = coords[1], rot = coords[2], large = coords[3], sweep = coords[4], ex = coords[5], ey = coords[6];
|
|
281
|
-
segs = arcToSegments(ex, ey, rx, ry, large, sweep, rot, x, y);
|
|
282
|
-
results = [];
|
|
283
|
-
for (j = 0, len = segs.length; j < len; j++) {
|
|
284
|
-
seg = segs[j];
|
|
285
|
-
bez = segmentToBezier.apply(null, seg);
|
|
286
|
-
results.push(doc.bezierCurveTo.apply(doc, bez));
|
|
287
|
-
}
|
|
288
|
-
return results;
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
arcToSegments = function(x, y, rx, ry, large, sweep, rotateX, ox, oy) {
|
|
292
|
-
var a00, a01, a10, a11, cos_th, d, i, j, pl, ref, result, segments, sfactor, sfactor_sq, sin_th, th, th0, th1, th2, th3, th_arc, x0, x1, xc, y0, y1, yc;
|
|
293
|
-
th = rotateX * (Math.PI / 180);
|
|
294
|
-
sin_th = Math.sin(th);
|
|
295
|
-
cos_th = Math.cos(th);
|
|
296
|
-
rx = Math.abs(rx);
|
|
297
|
-
ry = Math.abs(ry);
|
|
298
|
-
px = cos_th * (ox - x) * 0.5 + sin_th * (oy - y) * 0.5;
|
|
299
|
-
py = cos_th * (oy - y) * 0.5 - sin_th * (ox - x) * 0.5;
|
|
300
|
-
pl = (px * px) / (rx * rx) + (py * py) / (ry * ry);
|
|
301
|
-
if (pl > 1) {
|
|
302
|
-
pl = Math.sqrt(pl);
|
|
303
|
-
rx *= pl;
|
|
304
|
-
ry *= pl;
|
|
305
|
-
}
|
|
306
|
-
a00 = cos_th / rx;
|
|
307
|
-
a01 = sin_th / rx;
|
|
308
|
-
a10 = (-sin_th) / ry;
|
|
309
|
-
a11 = cos_th / ry;
|
|
310
|
-
x0 = a00 * ox + a01 * oy;
|
|
311
|
-
y0 = a10 * ox + a11 * oy;
|
|
312
|
-
x1 = a00 * x + a01 * y;
|
|
313
|
-
y1 = a10 * x + a11 * y;
|
|
314
|
-
d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
|
|
315
|
-
sfactor_sq = 1 / d - 0.25;
|
|
316
|
-
if (sfactor_sq < 0) {
|
|
317
|
-
sfactor_sq = 0;
|
|
318
|
-
}
|
|
319
|
-
sfactor = Math.sqrt(sfactor_sq);
|
|
320
|
-
if (sweep === large) {
|
|
321
|
-
sfactor = -sfactor;
|
|
322
|
-
}
|
|
323
|
-
xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);
|
|
324
|
-
yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0);
|
|
325
|
-
th0 = Math.atan2(y0 - yc, x0 - xc);
|
|
326
|
-
th1 = Math.atan2(y1 - yc, x1 - xc);
|
|
327
|
-
th_arc = th1 - th0;
|
|
328
|
-
if (th_arc < 0 && sweep === 1) {
|
|
329
|
-
th_arc += 2 * Math.PI;
|
|
330
|
-
} else if (th_arc > 0 && sweep === 0) {
|
|
331
|
-
th_arc -= 2 * Math.PI;
|
|
332
|
-
}
|
|
333
|
-
segments = Math.ceil(Math.abs(th_arc / (Math.PI * 0.5 + 0.001)));
|
|
334
|
-
result = [];
|
|
335
|
-
for (i = j = 0, ref = segments; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
|
|
336
|
-
th2 = th0 + i * th_arc / segments;
|
|
337
|
-
th3 = th0 + (i + 1) * th_arc / segments;
|
|
338
|
-
result[i] = [xc, yc, th2, th3, rx, ry, sin_th, cos_th];
|
|
339
|
-
}
|
|
340
|
-
return result;
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
segmentToBezier = function(cx, cy, th0, th1, rx, ry, sin_th, cos_th) {
|
|
344
|
-
var a00, a01, a10, a11, t, th_half, x1, x2, x3, y1, y2, y3;
|
|
345
|
-
a00 = cos_th * rx;
|
|
346
|
-
a01 = -sin_th * ry;
|
|
347
|
-
a10 = sin_th * rx;
|
|
348
|
-
a11 = cos_th * ry;
|
|
349
|
-
th_half = 0.5 * (th1 - th0);
|
|
350
|
-
t = (8 / 3) * Math.sin(th_half * 0.5) * Math.sin(th_half * 0.5) / Math.sin(th_half);
|
|
351
|
-
x1 = cx + Math.cos(th0) - t * Math.sin(th0);
|
|
352
|
-
y1 = cy + Math.sin(th0) + t * Math.cos(th0);
|
|
353
|
-
x3 = cx + Math.cos(th1);
|
|
354
|
-
y3 = cy + Math.sin(th1);
|
|
355
|
-
x2 = x3 + t * Math.sin(th1);
|
|
356
|
-
y2 = y3 - t * Math.cos(th1);
|
|
357
|
-
return [a00 * x1 + a01 * y1, a10 * x1 + a11 * y1, a00 * x2 + a01 * y2, a10 * x2 + a11 * y2, a00 * x3 + a01 * y3, a10 * x3 + a11 * y3];
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
return SVGPath;
|
|
361
|
-
|
|
362
|
-
})();
|
|
363
|
-
|
|
364
|
-
module.exports = SVGPath;
|
|
365
|
-
|
|
366
|
-
}).call(this);
|
package/js/reference.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// Generated by CoffeeScript 1.12.6
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
PDFReference - represents a reference to another object in the PDF object heirarchy
|
|
5
|
-
By Devon Govett
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
(function() {
|
|
9
|
-
var PDFObject, PDFReference, stream, zlib,
|
|
10
|
-
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
|
11
|
-
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
|
12
|
-
hasProp = {}.hasOwnProperty;
|
|
13
|
-
|
|
14
|
-
zlib = require('zlib');
|
|
15
|
-
|
|
16
|
-
stream = require('stream');
|
|
17
|
-
|
|
18
|
-
PDFReference = (function(superClass) {
|
|
19
|
-
extend(PDFReference, superClass);
|
|
20
|
-
|
|
21
|
-
function PDFReference(document, id, data) {
|
|
22
|
-
this.document = document;
|
|
23
|
-
this.id = id;
|
|
24
|
-
this.data = data != null ? data : {};
|
|
25
|
-
this.finalize = bind(this.finalize, this);
|
|
26
|
-
PDFReference.__super__.constructor.call(this, {
|
|
27
|
-
decodeStrings: false
|
|
28
|
-
});
|
|
29
|
-
this.gen = 0;
|
|
30
|
-
this.deflate = null;
|
|
31
|
-
this.compress = this.document.compress && !this.data.Filter;
|
|
32
|
-
this.uncompressedLength = 0;
|
|
33
|
-
this.chunks = [];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
PDFReference.prototype.initDeflate = function() {
|
|
37
|
-
this.data.Filter = 'FlateDecode';
|
|
38
|
-
this.deflate = zlib.createDeflate();
|
|
39
|
-
this.deflate.on('data', (function(_this) {
|
|
40
|
-
return function(chunk) {
|
|
41
|
-
_this.chunks.push(chunk);
|
|
42
|
-
return _this.data.Length += chunk.length;
|
|
43
|
-
};
|
|
44
|
-
})(this));
|
|
45
|
-
return this.deflate.on('end', this.finalize);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
PDFReference.prototype._write = function(chunk, encoding, callback) {
|
|
49
|
-
var base;
|
|
50
|
-
if (!Buffer.isBuffer(chunk)) {
|
|
51
|
-
chunk = new Buffer(chunk + '\n', 'binary');
|
|
52
|
-
}
|
|
53
|
-
this.uncompressedLength += chunk.length;
|
|
54
|
-
if ((base = this.data).Length == null) {
|
|
55
|
-
base.Length = 0;
|
|
56
|
-
}
|
|
57
|
-
if (this.compress) {
|
|
58
|
-
if (!this.deflate) {
|
|
59
|
-
this.initDeflate();
|
|
60
|
-
}
|
|
61
|
-
this.deflate.write(chunk);
|
|
62
|
-
} else {
|
|
63
|
-
this.chunks.push(chunk);
|
|
64
|
-
this.data.Length += chunk.length;
|
|
65
|
-
}
|
|
66
|
-
return callback();
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
PDFReference.prototype.end = function(chunk) {
|
|
70
|
-
PDFReference.__super__.end.apply(this, arguments);
|
|
71
|
-
if (this.deflate) {
|
|
72
|
-
return this.deflate.end();
|
|
73
|
-
} else {
|
|
74
|
-
return this.finalize();
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
PDFReference.prototype.finalize = function() {
|
|
79
|
-
var chunk, i, len, ref;
|
|
80
|
-
this.offset = this.document._offset;
|
|
81
|
-
this.document._write(this.id + " " + this.gen + " obj");
|
|
82
|
-
this.document._write(PDFObject.convert(this.data));
|
|
83
|
-
if (this.chunks.length) {
|
|
84
|
-
this.document._write('stream');
|
|
85
|
-
ref = this.chunks;
|
|
86
|
-
for (i = 0, len = ref.length; i < len; i++) {
|
|
87
|
-
chunk = ref[i];
|
|
88
|
-
this.document._write(chunk);
|
|
89
|
-
}
|
|
90
|
-
this.chunks.length = 0;
|
|
91
|
-
this.document._write('\nendstream');
|
|
92
|
-
}
|
|
93
|
-
this.document._write('endobj');
|
|
94
|
-
return this.document._refEnd(this);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
PDFReference.prototype.toString = function() {
|
|
98
|
-
return this.id + " " + this.gen + " R";
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
return PDFReference;
|
|
102
|
-
|
|
103
|
-
})(stream.Writable);
|
|
104
|
-
|
|
105
|
-
module.exports = PDFReference;
|
|
106
|
-
|
|
107
|
-
PDFObject = require('./object');
|
|
108
|
-
|
|
109
|
-
}).call(this);
|