pdfmake 0.2.4 → 0.3.0-beta.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/CHANGELOG.md +10 -27
- package/README.md +11 -7
- package/build/pdfmake.js +44733 -42435
- package/build/pdfmake.js.map +1 -1
- package/build/pdfmake.min.js +2 -2
- package/build/pdfmake.min.js.map +1 -1
- package/build/standard-fonts/Courier.js +27 -0
- package/build/standard-fonts/Helvetica.js +27 -0
- package/build/standard-fonts/Symbol.js +21 -0
- package/build/standard-fonts/Times.js +27 -0
- package/build/standard-fonts/ZapfDingbats.js +21 -0
- package/build/vfs_fonts.js +2 -2
- package/build-vfs.js +2 -2
- package/fonts/Roboto/Roboto-Italic.ttf +0 -0
- package/fonts/Roboto/Roboto-Medium.ttf +0 -0
- package/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
- package/fonts/Roboto/Roboto-Regular.ttf +0 -0
- package/fonts/Roboto.js +8 -0
- package/js/3rd-party/svg-to-pdfkit/source.js +4301 -0
- package/js/3rd-party/svg-to-pdfkit.js +11 -0
- package/js/DocMeasure.js +758 -0
- package/js/DocPreprocessor.js +291 -0
- package/js/DocumentContext.js +306 -0
- package/js/ElementWriter.js +400 -0
- package/js/LayoutBuilder.js +840 -0
- package/js/Line.js +125 -0
- package/js/OutputDocument.js +86 -0
- package/js/OutputDocumentServer.js +34 -0
- package/js/PDFDocument.js +190 -0
- package/js/PageElementWriter.js +165 -0
- package/js/PageSize.js +88 -0
- package/js/Printer.js +300 -0
- package/js/Renderer.js +463 -0
- package/js/SVGMeasure.js +89 -0
- package/js/StyleContextStack.js +206 -0
- package/js/TableProcessor.js +590 -0
- package/js/TextBreaker.js +182 -0
- package/js/TextDecorator.js +181 -0
- package/js/TextInlines.js +248 -0
- package/js/URLResolver.js +82 -0
- package/js/base.js +69 -0
- package/js/browser-extensions/OutputDocumentBrowser.js +131 -0
- package/js/browser-extensions/URLBrowserResolver.js +94 -0
- package/js/browser-extensions/fonts/Roboto.js +42 -0
- package/js/browser-extensions/index.js +70 -0
- package/js/browser-extensions/pdfMake.js +17 -0
- package/js/browser-extensions/standard-fonts/Courier.js +42 -0
- package/js/browser-extensions/standard-fonts/Helvetica.js +42 -0
- package/js/browser-extensions/standard-fonts/Symbol.js +27 -0
- package/js/browser-extensions/standard-fonts/Times.js +42 -0
- package/js/browser-extensions/standard-fonts/ZapfDingbats.js +27 -0
- package/js/browser-extensions/virtual-fs-cjs.js +3 -0
- package/js/columnCalculator.js +142 -0
- package/js/helpers/node.js +122 -0
- package/js/helpers/tools.js +48 -0
- package/js/helpers/variableType.js +52 -0
- package/js/index.js +21 -0
- package/js/qrEnc.js +810 -0
- package/js/standardPageSizes.js +57 -0
- package/js/tableLayouts.js +127 -0
- package/js/virtual-fs.js +77 -0
- package/package.json +26 -22
- package/src/3rd-party/svg-to-pdfkit.js +2 -2
- package/src/DocMeasure.js +703 -0
- package/src/DocPreprocessor.js +264 -0
- package/src/DocumentContext.js +309 -0
- package/src/ElementWriter.js +394 -0
- package/src/LayoutBuilder.js +821 -0
- package/src/Line.js +114 -0
- package/src/OutputDocument.js +78 -0
- package/src/OutputDocumentServer.js +26 -0
- package/src/PDFDocument.js +174 -0
- package/src/PageElementWriter.js +160 -0
- package/src/PageSize.js +53 -0
- package/src/Printer.js +277 -0
- package/src/Renderer.js +405 -0
- package/src/SVGMeasure.js +79 -0
- package/src/StyleContextStack.js +216 -0
- package/src/TableProcessor.js +558 -0
- package/src/TextBreaker.js +149 -0
- package/src/TextDecorator.js +161 -0
- package/src/TextInlines.js +223 -0
- package/src/URLResolver.js +72 -0
- package/src/base.js +61 -0
- package/src/browser-extensions/OutputDocumentBrowser.js +117 -0
- package/src/browser-extensions/URLBrowserResolver.js +49 -53
- package/src/browser-extensions/fonts/Roboto.js +27 -0
- package/src/browser-extensions/index.js +55 -0
- package/src/browser-extensions/pdfMake.js +10 -282
- package/src/browser-extensions/standard-fonts/Courier.js +27 -0
- package/src/browser-extensions/standard-fonts/Helvetica.js +27 -0
- package/src/browser-extensions/standard-fonts/Symbol.js +21 -0
- package/src/browser-extensions/standard-fonts/Times.js +27 -0
- package/src/browser-extensions/standard-fonts/ZapfDingbats.js +21 -0
- package/src/browser-extensions/virtual-fs-cjs.js +1 -0
- package/src/columnCalculator.js +29 -32
- package/src/helpers/node.js +110 -0
- package/src/helpers/tools.js +39 -0
- package/src/helpers/variableType.js +39 -0
- package/src/index.js +16 -0
- package/src/qrEnc.js +15 -10
- package/src/standardPageSizes.js +1 -3
- package/src/tableLayouts.js +100 -0
- package/src/virtual-fs.js +66 -0
- package/standard-fonts/Courier.js +8 -0
- package/standard-fonts/Helvetica.js +9 -0
- package/standard-fonts/Symbol.js +5 -0
- package/standard-fonts/Times.js +8 -0
- package/standard-fonts/ZapfDingbats.js +5 -0
- package/src/browser-extensions/virtual-fs.js +0 -55
- package/src/docMeasure.js +0 -807
- package/src/docPreprocessor.js +0 -255
- package/src/documentContext.js +0 -314
- package/src/elementWriter.js +0 -322
- package/src/fontProvider.js +0 -68
- package/src/helpers.js +0 -126
- package/src/imageMeasure.js +0 -51
- package/src/layoutBuilder.js +0 -807
- package/src/line.js +0 -91
- package/src/pageElementWriter.js +0 -174
- package/src/pdfKitEngine.js +0 -21
- package/src/printer.js +0 -705
- package/src/styleContextStack.js +0 -179
- package/src/svgMeasure.js +0 -70
- package/src/tableProcessor.js +0 -561
- package/src/textDecorator.js +0 -157
- package/src/textTools.js +0 -373
- package/src/traversalTracker.js +0 -47
package/src/line.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates an instance of Line
|
|
5
|
-
*
|
|
6
|
-
* @constructor
|
|
7
|
-
* @this {Line}
|
|
8
|
-
* @param {Number} Maximum width this line can have
|
|
9
|
-
*/
|
|
10
|
-
function Line(maxWidth) {
|
|
11
|
-
this.maxWidth = maxWidth;
|
|
12
|
-
this.leadingCut = 0;
|
|
13
|
-
this.trailingCut = 0;
|
|
14
|
-
this.inlineWidths = 0;
|
|
15
|
-
this.inlines = [];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
Line.prototype.getAscenderHeight = function () {
|
|
19
|
-
var y = 0;
|
|
20
|
-
|
|
21
|
-
this.inlines.forEach(function (inline) {
|
|
22
|
-
y = Math.max(y, inline.font.ascender / 1000 * inline.fontSize);
|
|
23
|
-
});
|
|
24
|
-
return y;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
Line.prototype.hasEnoughSpaceForInline = function (inline, nextInlines) {
|
|
28
|
-
nextInlines = nextInlines || [];
|
|
29
|
-
|
|
30
|
-
if (this.inlines.length === 0) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
if (this.newLineForced) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var inlineWidth = inline.width;
|
|
38
|
-
var inlineTrailingCut = inline.trailingCut || 0;
|
|
39
|
-
if (inline.noNewLine) {
|
|
40
|
-
for (var i = 0, l = nextInlines.length; i < l; i++) {
|
|
41
|
-
var nextInline = nextInlines[i];
|
|
42
|
-
inlineWidth += nextInline.width;
|
|
43
|
-
inlineTrailingCut += nextInline.trailingCut || 0;
|
|
44
|
-
if (!nextInline.noNewLine) {
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return (this.inlineWidths + inlineWidth - this.leadingCut - inlineTrailingCut) <= this.maxWidth;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
Line.prototype.addInline = function (inline) {
|
|
54
|
-
if (this.inlines.length === 0) {
|
|
55
|
-
this.leadingCut = inline.leadingCut || 0;
|
|
56
|
-
}
|
|
57
|
-
this.trailingCut = inline.trailingCut || 0;
|
|
58
|
-
|
|
59
|
-
inline.x = this.inlineWidths - this.leadingCut;
|
|
60
|
-
|
|
61
|
-
this.inlines.push(inline);
|
|
62
|
-
this.inlineWidths += inline.width;
|
|
63
|
-
|
|
64
|
-
if (inline.lineEnd) {
|
|
65
|
-
this.newLineForced = true;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
Line.prototype.getWidth = function () {
|
|
70
|
-
return this.inlineWidths - this.leadingCut - this.trailingCut;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
Line.prototype.getAvailableWidth = function () {
|
|
74
|
-
return this.maxWidth - this.getWidth();
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Returns line height
|
|
79
|
-
* @return {Number}
|
|
80
|
-
*/
|
|
81
|
-
Line.prototype.getHeight = function () {
|
|
82
|
-
var max = 0;
|
|
83
|
-
|
|
84
|
-
this.inlines.forEach(function (item) {
|
|
85
|
-
max = Math.max(max, item.height || 0);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
return max;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
module.exports = Line;
|
package/src/pageElementWriter.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var isUndefined = require('./helpers').isUndefined;
|
|
4
|
-
var ElementWriter = require('./elementWriter');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creates an instance of PageElementWriter - an extended ElementWriter
|
|
8
|
-
* which can handle:
|
|
9
|
-
* - page-breaks (it adds new pages when there's not enough space left),
|
|
10
|
-
* - repeatable fragments (like table-headers, which are repeated everytime
|
|
11
|
-
* a page-break occurs)
|
|
12
|
-
* - transactions (used for unbreakable-blocks when we want to make sure
|
|
13
|
-
* whole block will be rendered on the same page)
|
|
14
|
-
*/
|
|
15
|
-
function PageElementWriter(context, tracker) {
|
|
16
|
-
this.transactionLevel = 0;
|
|
17
|
-
this.repeatables = [];
|
|
18
|
-
this.tracker = tracker;
|
|
19
|
-
this.writer = new ElementWriter(context, tracker);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function fitOnPage(self, addFct) {
|
|
23
|
-
var position = addFct(self);
|
|
24
|
-
if (!position) {
|
|
25
|
-
self.moveToNextPage();
|
|
26
|
-
position = addFct(self);
|
|
27
|
-
}
|
|
28
|
-
return position;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
PageElementWriter.prototype.addLine = function (line, dontUpdateContextPosition, index) {
|
|
32
|
-
return fitOnPage(this, function (self) {
|
|
33
|
-
return self.writer.addLine(line, dontUpdateContextPosition, index);
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
PageElementWriter.prototype.addImage = function (image, index) {
|
|
38
|
-
return fitOnPage(this, function (self) {
|
|
39
|
-
return self.writer.addImage(image, index);
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
PageElementWriter.prototype.addSVG = function (image, index) {
|
|
44
|
-
return fitOnPage(this, function (self) {
|
|
45
|
-
return self.writer.addSVG(image, index);
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
PageElementWriter.prototype.addQr = function (qr, index) {
|
|
50
|
-
return fitOnPage(this, function (self) {
|
|
51
|
-
return self.writer.addQr(qr, index);
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
PageElementWriter.prototype.addVector = function (vector, ignoreContextX, ignoreContextY, index) {
|
|
56
|
-
return this.writer.addVector(vector, ignoreContextX, ignoreContextY, index);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
PageElementWriter.prototype.beginClip = function (width, height) {
|
|
60
|
-
return this.writer.beginClip(width, height);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
PageElementWriter.prototype.endClip = function () {
|
|
64
|
-
return this.writer.endClip();
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
PageElementWriter.prototype.alignCanvas = function (node) {
|
|
68
|
-
this.writer.alignCanvas(node);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
PageElementWriter.prototype.addFragment = function (fragment, useBlockXOffset, useBlockYOffset, dontUpdateContextPosition) {
|
|
72
|
-
if (!this.writer.addFragment(fragment, useBlockXOffset, useBlockYOffset, dontUpdateContextPosition)) {
|
|
73
|
-
this.moveToNextPage();
|
|
74
|
-
this.writer.addFragment(fragment, useBlockXOffset, useBlockYOffset, dontUpdateContextPosition);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
PageElementWriter.prototype.moveToNextPage = function (pageOrientation) {
|
|
79
|
-
|
|
80
|
-
var nextPage = this.writer.context.moveToNextPage(pageOrientation);
|
|
81
|
-
|
|
82
|
-
// moveToNextPage is called multiple times for table, because is called for each column
|
|
83
|
-
// and repeatables are inserted only in the first time. If columns are used, is needed
|
|
84
|
-
// call for table in first column and then for table in the second column (is other repeatables).
|
|
85
|
-
this.repeatables.forEach(function (rep) {
|
|
86
|
-
if (isUndefined(rep.insertedOnPages[this.writer.context.page])) {
|
|
87
|
-
rep.insertedOnPages[this.writer.context.page] = true;
|
|
88
|
-
this.writer.addFragment(rep, true);
|
|
89
|
-
} else {
|
|
90
|
-
this.writer.context.moveDown(rep.height);
|
|
91
|
-
}
|
|
92
|
-
}, this);
|
|
93
|
-
|
|
94
|
-
this.writer.tracker.emit('pageChanged', {
|
|
95
|
-
prevPage: nextPage.prevPage,
|
|
96
|
-
prevY: nextPage.prevY,
|
|
97
|
-
y: this.writer.context.y
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
PageElementWriter.prototype.beginUnbreakableBlock = function (width, height) {
|
|
102
|
-
if (this.transactionLevel++ === 0) {
|
|
103
|
-
this.originalX = this.writer.context.x;
|
|
104
|
-
this.writer.pushContext(width, height);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
PageElementWriter.prototype.commitUnbreakableBlock = function (forcedX, forcedY) {
|
|
109
|
-
if (--this.transactionLevel === 0) {
|
|
110
|
-
var unbreakableContext = this.writer.context;
|
|
111
|
-
this.writer.popContext();
|
|
112
|
-
|
|
113
|
-
var nbPages = unbreakableContext.pages.length;
|
|
114
|
-
if (nbPages > 0) {
|
|
115
|
-
// no support for multi-page unbreakableBlocks
|
|
116
|
-
var fragment = unbreakableContext.pages[0];
|
|
117
|
-
fragment.xOffset = forcedX;
|
|
118
|
-
fragment.yOffset = forcedY;
|
|
119
|
-
|
|
120
|
-
//TODO: vectors can influence height in some situations
|
|
121
|
-
if (nbPages > 1) {
|
|
122
|
-
// on out-of-context blocs (headers, footers, background) height should be the whole DocumentContext height
|
|
123
|
-
if (forcedX !== undefined || forcedY !== undefined) {
|
|
124
|
-
fragment.height = unbreakableContext.getCurrentPage().pageSize.height - unbreakableContext.pageMargins.top - unbreakableContext.pageMargins.bottom;
|
|
125
|
-
} else {
|
|
126
|
-
fragment.height = this.writer.context.getCurrentPage().pageSize.height - this.writer.context.pageMargins.top - this.writer.context.pageMargins.bottom;
|
|
127
|
-
for (var i = 0, l = this.repeatables.length; i < l; i++) {
|
|
128
|
-
fragment.height -= this.repeatables[i].height;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
fragment.height = unbreakableContext.y;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (forcedX !== undefined || forcedY !== undefined) {
|
|
136
|
-
this.writer.addFragment(fragment, true, true, true);
|
|
137
|
-
} else {
|
|
138
|
-
this.addFragment(fragment);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
PageElementWriter.prototype.currentBlockToRepeatable = function () {
|
|
145
|
-
var unbreakableContext = this.writer.context;
|
|
146
|
-
var rep = { items: [] };
|
|
147
|
-
|
|
148
|
-
unbreakableContext.pages[0].items.forEach(function (item) {
|
|
149
|
-
rep.items.push(item);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
rep.xOffset = this.originalX;
|
|
153
|
-
|
|
154
|
-
//TODO: vectors can influence height in some situations
|
|
155
|
-
rep.height = unbreakableContext.y;
|
|
156
|
-
|
|
157
|
-
rep.insertedOnPages = [];
|
|
158
|
-
|
|
159
|
-
return rep;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
PageElementWriter.prototype.pushToRepeatables = function (rep) {
|
|
163
|
-
this.repeatables.push(rep);
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
PageElementWriter.prototype.popFromRepeatables = function () {
|
|
167
|
-
this.repeatables.pop();
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
PageElementWriter.prototype.context = function () {
|
|
171
|
-
return this.writer.context;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
module.exports = PageElementWriter;
|
package/src/pdfKitEngine.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function _interopDefault(ex) {
|
|
4
|
-
return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
var PdfKit = _interopDefault(require('@foliojs-fork/pdfkit'));
|
|
8
|
-
|
|
9
|
-
function getEngineInstance() {
|
|
10
|
-
return PdfKit;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function createPdfDocument(options) {
|
|
14
|
-
options = options || {};
|
|
15
|
-
return new PdfKit(options);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
getEngineInstance: getEngineInstance,
|
|
20
|
-
createPdfDocument: createPdfDocument
|
|
21
|
-
};
|