pdfmake 0.3.0-beta.7 → 0.3.0-beta.8

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 (49) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/pdfmake.js +2654 -2525
  3. package/build/pdfmake.js.map +1 -1
  4. package/build/pdfmake.min.js +2 -2
  5. package/build/pdfmake.min.js.map +1 -1
  6. package/package.json +1 -1
  7. package/js/3rd-party/svg-to-pdfkit/source.js +0 -3626
  8. package/js/3rd-party/svg-to-pdfkit.js +0 -7
  9. package/js/DocMeasure.js +0 -627
  10. package/js/DocPreprocessor.js +0 -238
  11. package/js/DocumentContext.js +0 -265
  12. package/js/ElementWriter.js +0 -331
  13. package/js/LayoutBuilder.js +0 -694
  14. package/js/Line.js +0 -105
  15. package/js/OutputDocument.js +0 -76
  16. package/js/OutputDocumentServer.js +0 -27
  17. package/js/PDFDocument.js +0 -144
  18. package/js/PageElementWriter.js +0 -140
  19. package/js/PageSize.js +0 -74
  20. package/js/Printer.js +0 -291
  21. package/js/Renderer.js +0 -375
  22. package/js/SVGMeasure.js +0 -69
  23. package/js/StyleContextStack.js +0 -180
  24. package/js/TableProcessor.js +0 -511
  25. package/js/TextBreaker.js +0 -139
  26. package/js/TextDecorator.js +0 -143
  27. package/js/TextInlines.js +0 -206
  28. package/js/URLResolver.js +0 -73
  29. package/js/base.js +0 -52
  30. package/js/browser-extensions/OutputDocumentBrowser.js +0 -118
  31. package/js/browser-extensions/URLBrowserResolver.js +0 -76
  32. package/js/browser-extensions/fonts/Roboto.js +0 -38
  33. package/js/browser-extensions/index.js +0 -53
  34. package/js/browser-extensions/pdfMake.js +0 -15
  35. package/js/browser-extensions/standard-fonts/Courier.js +0 -38
  36. package/js/browser-extensions/standard-fonts/Helvetica.js +0 -38
  37. package/js/browser-extensions/standard-fonts/Symbol.js +0 -23
  38. package/js/browser-extensions/standard-fonts/Times.js +0 -38
  39. package/js/browser-extensions/standard-fonts/ZapfDingbats.js +0 -23
  40. package/js/browser-extensions/virtual-fs-cjs.js +0 -3
  41. package/js/columnCalculator.js +0 -129
  42. package/js/helpers/node.js +0 -98
  43. package/js/helpers/tools.js +0 -40
  44. package/js/helpers/variableType.js +0 -47
  45. package/js/index.js +0 -15
  46. package/js/qrEnc.js +0 -721
  47. package/js/standardPageSizes.js +0 -56
  48. package/js/tableLayouts.js +0 -98
  49. package/js/virtual-fs.js +0 -60
@@ -1,331 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _variableType = require("./helpers/variableType");
6
- var _tools = require("./helpers/tools");
7
- var _DocumentContext = _interopRequireDefault(require("./DocumentContext"));
8
- var _events = require("events");
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /**
11
- * A line/vector writer, which adds elements to current page and sets
12
- * their positions based on the context
13
- */
14
- class ElementWriter extends _events.EventEmitter {
15
- constructor(context) {
16
- super();
17
- this._context = context;
18
- this.contextStack = [];
19
- }
20
- context() {
21
- return this._context;
22
- }
23
- addLine(line, dontUpdateContextPosition, index) {
24
- let height = line.getHeight();
25
- let context = this.context();
26
- let page = context.getCurrentPage();
27
- let position = this.getCurrentPositionOnPage();
28
- if (context.availableHeight < height || !page) {
29
- return false;
30
- }
31
- line.x = context.x + (line.x || 0);
32
- line.y = context.y + (line.y || 0);
33
- this.alignLine(line);
34
- addPageItem(page, {
35
- type: 'line',
36
- item: line
37
- }, index);
38
- this.emit('lineAdded', line);
39
- if (!dontUpdateContextPosition) {
40
- context.moveDown(height);
41
- }
42
- return position;
43
- }
44
- alignLine(line) {
45
- let width = this.context().availableWidth;
46
- let lineWidth = line.getWidth();
47
- let alignment = line.inlines && line.inlines.length > 0 && line.inlines[0].alignment;
48
- let offset = 0;
49
- switch (alignment) {
50
- case 'right':
51
- offset = width - lineWidth;
52
- break;
53
- case 'center':
54
- offset = (width - lineWidth) / 2;
55
- break;
56
- }
57
- if (offset) {
58
- line.x = (line.x || 0) + offset;
59
- }
60
- if (alignment === 'justify' && !line.newLineForced && !line.lastLineInParagraph && line.inlines.length > 1) {
61
- let additionalSpacing = (width - lineWidth) / (line.inlines.length - 1);
62
- for (let i = 1, l = line.inlines.length; i < l; i++) {
63
- offset = i * additionalSpacing;
64
- line.inlines[i].x += offset;
65
- line.inlines[i].justifyShift = additionalSpacing;
66
- }
67
- }
68
- }
69
- addImage(image, index) {
70
- let context = this.context();
71
- let page = context.getCurrentPage();
72
- let position = this.getCurrentPositionOnPage();
73
- if (!page || image.absolutePosition === undefined && context.availableHeight < image._height && page.items.length > 0) {
74
- return false;
75
- }
76
- if (image._x === undefined) {
77
- image._x = image.x || 0;
78
- }
79
- image.x = context.x + image._x;
80
- image.y = context.y;
81
- this.alignImage(image);
82
- addPageItem(page, {
83
- type: 'image',
84
- item: image
85
- }, index);
86
- context.moveDown(image._height);
87
- return position;
88
- }
89
- addCanvas(node, index) {
90
- let context = this.context();
91
- let page = context.getCurrentPage();
92
- let positions = [];
93
- let height = node._minHeight;
94
- if (!page || node.absolutePosition === undefined && context.availableHeight < height) {
95
- // TODO: support for canvas larger than a page
96
- // TODO: support for other overflow methods
97
-
98
- return false;
99
- }
100
- this.alignCanvas(node);
101
- node.canvas.forEach(function (vector) {
102
- let position = this.addVector(vector, false, false, index);
103
- positions.push(position);
104
- if (index !== undefined) {
105
- index++;
106
- }
107
- }, this);
108
- context.moveDown(height);
109
- return positions;
110
- }
111
- addSVG(image, index) {
112
- // TODO: same as addImage
113
- let context = this.context();
114
- let page = context.getCurrentPage();
115
- let position = this.getCurrentPositionOnPage();
116
- if (!page || image.absolutePosition === undefined && context.availableHeight < image._height && page.items.length > 0) {
117
- return false;
118
- }
119
- if (image._x === undefined) {
120
- image._x = image.x || 0;
121
- }
122
- image.x = context.x + image._x;
123
- image.y = context.y;
124
- this.alignImage(image);
125
- addPageItem(page, {
126
- type: 'svg',
127
- item: image
128
- }, index);
129
- context.moveDown(image._height);
130
- return position;
131
- }
132
- addQr(qr, index) {
133
- let context = this.context();
134
- let page = context.getCurrentPage();
135
- let position = this.getCurrentPositionOnPage();
136
- if (!page || qr.absolutePosition === undefined && context.availableHeight < qr._height) {
137
- return false;
138
- }
139
- if (qr._x === undefined) {
140
- qr._x = qr.x || 0;
141
- }
142
- qr.x = context.x + qr._x;
143
- qr.y = context.y;
144
- this.alignImage(qr);
145
- for (let i = 0, l = qr._canvas.length; i < l; i++) {
146
- let vector = qr._canvas[i];
147
- vector.x += qr.x;
148
- vector.y += qr.y;
149
- this.addVector(vector, true, true, index);
150
- }
151
- context.moveDown(qr._height);
152
- return position;
153
- }
154
- addAttachment(attachment, index) {
155
- let context = this.context();
156
- let page = context.getCurrentPage();
157
- let position = this.getCurrentPositionOnPage();
158
- if (!page || attachment.absolutePosition === undefined && context.availableHeight < attachment._height && page.items.length > 0) {
159
- return false;
160
- }
161
- if (attachment._x === undefined) {
162
- attachment._x = attachment.x || 0;
163
- }
164
- attachment.x = context.x + attachment._x;
165
- attachment.y = context.y;
166
- addPageItem(page, {
167
- type: 'attachment',
168
- item: attachment
169
- }, index);
170
- context.moveDown(attachment._height);
171
- return position;
172
- }
173
- alignImage(image) {
174
- let width = this.context().availableWidth;
175
- let imageWidth = image._minWidth;
176
- let offset = 0;
177
- switch (image._alignment) {
178
- case 'right':
179
- offset = width - imageWidth;
180
- break;
181
- case 'center':
182
- offset = (width - imageWidth) / 2;
183
- break;
184
- }
185
- if (offset) {
186
- image.x = (image.x || 0) + offset;
187
- }
188
- }
189
- alignCanvas(node) {
190
- let width = this.context().availableWidth;
191
- let canvasWidth = node._minWidth;
192
- let offset = 0;
193
- switch (node._alignment) {
194
- case 'right':
195
- offset = width - canvasWidth;
196
- break;
197
- case 'center':
198
- offset = (width - canvasWidth) / 2;
199
- break;
200
- }
201
- if (offset) {
202
- node.canvas.forEach(vector => {
203
- (0, _tools.offsetVector)(vector, offset, 0);
204
- });
205
- }
206
- }
207
- addVector(vector, ignoreContextX, ignoreContextY, index) {
208
- let context = this.context();
209
- let page = context.getCurrentPage();
210
- let position = this.getCurrentPositionOnPage();
211
- if (page) {
212
- (0, _tools.offsetVector)(vector, ignoreContextX ? 0 : context.x, ignoreContextY ? 0 : context.y);
213
- addPageItem(page, {
214
- type: 'vector',
215
- item: vector
216
- }, index);
217
- return position;
218
- }
219
- }
220
- beginClip(width, height) {
221
- let ctx = this.context();
222
- let page = ctx.getCurrentPage();
223
- page.items.push({
224
- type: 'beginClip',
225
- item: {
226
- x: ctx.x,
227
- y: ctx.y,
228
- width: width,
229
- height: height
230
- }
231
- });
232
- return true;
233
- }
234
- endClip() {
235
- let ctx = this.context();
236
- let page = ctx.getCurrentPage();
237
- page.items.push({
238
- type: 'endClip'
239
- });
240
- return true;
241
- }
242
- addFragment(block, useBlockXOffset, useBlockYOffset, dontUpdateContextPosition) {
243
- let ctx = this.context();
244
- let page = ctx.getCurrentPage();
245
- if (!useBlockXOffset && block.height > ctx.availableHeight) {
246
- return false;
247
- }
248
- block.items.forEach(item => {
249
- switch (item.type) {
250
- case 'line':
251
- var l = item.item.clone();
252
- if (l._node) {
253
- l._node.positions[0].pageNumber = ctx.page + 1;
254
- }
255
- l.x = (l.x || 0) + (useBlockXOffset ? block.xOffset || 0 : ctx.x);
256
- l.y = (l.y || 0) + (useBlockYOffset ? block.yOffset || 0 : ctx.y);
257
- page.items.push({
258
- type: 'line',
259
- item: l
260
- });
261
- break;
262
- case 'vector':
263
- var v = (0, _tools.pack)(item.item);
264
- (0, _tools.offsetVector)(v, useBlockXOffset ? block.xOffset || 0 : ctx.x, useBlockYOffset ? block.yOffset || 0 : ctx.y);
265
- page.items.push({
266
- type: 'vector',
267
- item: v
268
- });
269
- break;
270
- case 'image':
271
- case 'svg':
272
- var img = (0, _tools.pack)(item.item);
273
- img.x = (img.x || 0) + (useBlockXOffset ? block.xOffset || 0 : ctx.x);
274
- img.y = (img.y || 0) + (useBlockYOffset ? block.yOffset || 0 : ctx.y);
275
- page.items.push({
276
- type: item.type,
277
- item: img
278
- });
279
- break;
280
- }
281
- });
282
- if (!dontUpdateContextPosition) {
283
- ctx.moveDown(block.height);
284
- }
285
- return true;
286
- }
287
-
288
- /**
289
- * Pushes the provided context onto the stack or creates a new one
290
- *
291
- * pushContext(context) - pushes the provided context and makes it current
292
- * pushContext(width, height) - creates and pushes a new context with the specified width and height
293
- * pushContext() - creates a new context for unbreakable blocks (with current availableWidth and full-page-height)
294
- *
295
- * @param {object|number} contextOrWidth
296
- * @param {number} height
297
- */
298
- pushContext(contextOrWidth, height) {
299
- if (contextOrWidth === undefined) {
300
- height = this.context().getCurrentPage().height - this.context().pageMargins.top - this.context().pageMargins.bottom;
301
- contextOrWidth = this.context().availableWidth;
302
- }
303
- if ((0, _variableType.isNumber)(contextOrWidth)) {
304
- contextOrWidth = new _DocumentContext.default({
305
- width: contextOrWidth,
306
- height: height
307
- }, {
308
- left: 0,
309
- right: 0,
310
- top: 0,
311
- bottom: 0
312
- });
313
- }
314
- this.contextStack.push(this.context());
315
- this._context = contextOrWidth;
316
- }
317
- popContext() {
318
- this._context = this.contextStack.pop();
319
- }
320
- getCurrentPositionOnPage() {
321
- return (this.contextStack[0] || this.context()).getCurrentPosition();
322
- }
323
- }
324
- function addPageItem(page, item, index) {
325
- if (index === null || index === undefined || index < 0 || index > page.items.length) {
326
- page.items.push(item);
327
- } else {
328
- page.items.splice(index, 0, item);
329
- }
330
- }
331
- var _default = exports.default = ElementWriter;