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/styleContextStack.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var isString = require('./helpers').isString;
|
|
4
|
-
var isArray = require('./helpers').isArray;
|
|
5
|
-
var isUndefined = require('./helpers').isUndefined;
|
|
6
|
-
var isNull = require('./helpers').isNull;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Creates an instance of StyleContextStack used for style inheritance and style overrides
|
|
10
|
-
*
|
|
11
|
-
* @constructor
|
|
12
|
-
* @this {StyleContextStack}
|
|
13
|
-
* @param {Object} named styles dictionary
|
|
14
|
-
* @param {Object} optional default style definition
|
|
15
|
-
*/
|
|
16
|
-
function StyleContextStack(styleDictionary, defaultStyle) {
|
|
17
|
-
this.defaultStyle = defaultStyle || {};
|
|
18
|
-
this.styleDictionary = styleDictionary;
|
|
19
|
-
this.styleOverrides = [];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Creates cloned version of current stack
|
|
24
|
-
* @return {StyleContextStack} current stack snapshot
|
|
25
|
-
*/
|
|
26
|
-
StyleContextStack.prototype.clone = function () {
|
|
27
|
-
var stack = new StyleContextStack(this.styleDictionary, this.defaultStyle);
|
|
28
|
-
|
|
29
|
-
this.styleOverrides.forEach(function (item) {
|
|
30
|
-
stack.styleOverrides.push(item);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return stack;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Pushes style-name or style-overrides-object onto the stack for future evaluation
|
|
38
|
-
*
|
|
39
|
-
* @param {String|Object} styleNameOrOverride style-name (referring to styleDictionary) or
|
|
40
|
-
* a new dictionary defining overriding properties
|
|
41
|
-
*/
|
|
42
|
-
StyleContextStack.prototype.push = function (styleNameOrOverride) {
|
|
43
|
-
this.styleOverrides.push(styleNameOrOverride);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Removes last style-name or style-overrides-object from the stack
|
|
48
|
-
*
|
|
49
|
-
* @param {Number} howMany - optional number of elements to be popped (if not specified,
|
|
50
|
-
* one element will be removed from the stack)
|
|
51
|
-
*/
|
|
52
|
-
StyleContextStack.prototype.pop = function (howMany) {
|
|
53
|
-
howMany = howMany || 1;
|
|
54
|
-
|
|
55
|
-
while (howMany-- > 0) {
|
|
56
|
-
this.styleOverrides.pop();
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Creates a set of named styles or/and a style-overrides-object based on the item,
|
|
62
|
-
* pushes those elements onto the stack for future evaluation and returns the number
|
|
63
|
-
* of elements pushed, so they can be easily poped then.
|
|
64
|
-
*
|
|
65
|
-
* @param {Object} item - an object with optional style property and/or style overrides
|
|
66
|
-
* @return the number of items pushed onto the stack
|
|
67
|
-
*/
|
|
68
|
-
StyleContextStack.prototype.autopush = function (item) {
|
|
69
|
-
if (isString(item)) {
|
|
70
|
-
return 0;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
var styleNames = [];
|
|
74
|
-
|
|
75
|
-
if (item.style) {
|
|
76
|
-
if (isArray(item.style)) {
|
|
77
|
-
styleNames = item.style;
|
|
78
|
-
} else {
|
|
79
|
-
styleNames = [item.style];
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
for (var i = 0, l = styleNames.length; i < l; i++) {
|
|
84
|
-
this.push(styleNames[i]);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
var styleProperties = [
|
|
88
|
-
'font',
|
|
89
|
-
'fontSize',
|
|
90
|
-
'fontFeatures',
|
|
91
|
-
'bold',
|
|
92
|
-
'italics',
|
|
93
|
-
'alignment',
|
|
94
|
-
'color',
|
|
95
|
-
'columnGap',
|
|
96
|
-
'fillColor',
|
|
97
|
-
'fillOpacity',
|
|
98
|
-
'decoration',
|
|
99
|
-
'decorationStyle',
|
|
100
|
-
'decorationColor',
|
|
101
|
-
'background',
|
|
102
|
-
'lineHeight',
|
|
103
|
-
'characterSpacing',
|
|
104
|
-
'noWrap',
|
|
105
|
-
'markerColor',
|
|
106
|
-
'leadingIndent',
|
|
107
|
-
'sup',
|
|
108
|
-
'sub'
|
|
109
|
-
//'tableCellPadding'
|
|
110
|
-
// 'cellBorder',
|
|
111
|
-
// 'headerCellBorder',
|
|
112
|
-
// 'oddRowCellBorder',
|
|
113
|
-
// 'evenRowCellBorder',
|
|
114
|
-
// 'tableBorder'
|
|
115
|
-
];
|
|
116
|
-
var styleOverrideObject = {};
|
|
117
|
-
var pushStyleOverrideObject = false;
|
|
118
|
-
|
|
119
|
-
styleProperties.forEach(function (key) {
|
|
120
|
-
if (!isUndefined(item[key]) && !isNull(item[key])) {
|
|
121
|
-
styleOverrideObject[key] = item[key];
|
|
122
|
-
pushStyleOverrideObject = true;
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
if (pushStyleOverrideObject) {
|
|
127
|
-
this.push(styleOverrideObject);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return styleNames.length + (pushStyleOverrideObject ? 1 : 0);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Automatically pushes elements onto the stack, using autopush based on item,
|
|
135
|
-
* executes callback and then pops elements back. Returns value returned by callback
|
|
136
|
-
*
|
|
137
|
-
* @param {Object} item - an object with optional style property and/or style overrides
|
|
138
|
-
* @param {Function} function to be called between autopush and pop
|
|
139
|
-
* @return {Object} value returned by callback
|
|
140
|
-
*/
|
|
141
|
-
StyleContextStack.prototype.auto = function (item, callback) {
|
|
142
|
-
var pushedItems = this.autopush(item);
|
|
143
|
-
var result = callback();
|
|
144
|
-
|
|
145
|
-
if (pushedItems > 0) {
|
|
146
|
-
this.pop(pushedItems);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return result;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Evaluates stack and returns value of a named property
|
|
154
|
-
*
|
|
155
|
-
* @param {String} property - property name
|
|
156
|
-
* @return property value or null if not found
|
|
157
|
-
*/
|
|
158
|
-
StyleContextStack.prototype.getProperty = function (property) {
|
|
159
|
-
if (this.styleOverrides) {
|
|
160
|
-
for (var i = this.styleOverrides.length - 1; i >= 0; i--) {
|
|
161
|
-
var item = this.styleOverrides[i];
|
|
162
|
-
|
|
163
|
-
if (isString(item)) {
|
|
164
|
-
// named-style-override
|
|
165
|
-
var style = this.styleDictionary[item];
|
|
166
|
-
if (style && !isUndefined(style[property]) && !isNull(style[property])) {
|
|
167
|
-
return style[property];
|
|
168
|
-
}
|
|
169
|
-
} else if (!isUndefined(item[property]) && !isNull(item[property])) {
|
|
170
|
-
// style-overrides-object
|
|
171
|
-
return item[property];
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return this.defaultStyle && this.defaultStyle[property];
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
module.exports = StyleContextStack;
|
package/src/svgMeasure.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var xmldoc = require('xmldoc');
|
|
4
|
-
|
|
5
|
-
/** Strip unit postfix, parse number, but return undefined instead of NaN for bad input */
|
|
6
|
-
function stripUnits(textVal) {
|
|
7
|
-
var n = parseFloat(textVal);
|
|
8
|
-
if (typeof n !== 'number' || isNaN(n)) {
|
|
9
|
-
return undefined;
|
|
10
|
-
}
|
|
11
|
-
return n;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** Make sure it's valid XML and the root tage is <svg/>, returns xmldoc DOM */
|
|
15
|
-
function parseSVG(svgString) {
|
|
16
|
-
var doc;
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
doc = new xmldoc.XmlDocument(svgString);
|
|
20
|
-
} catch (err) {
|
|
21
|
-
throw new Error('SVGMeasure: ' + err);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (doc.name !== "svg") {
|
|
25
|
-
throw new Error('SVGMeasure: expected <svg> document');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return doc;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function SVGMeasure() {
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
SVGMeasure.prototype.measureSVG = function (svgString) {
|
|
35
|
-
|
|
36
|
-
var doc = parseSVG(svgString);
|
|
37
|
-
|
|
38
|
-
var docWidth = stripUnits(doc.attr.width);
|
|
39
|
-
var docHeight = stripUnits(doc.attr.height);
|
|
40
|
-
|
|
41
|
-
if ((docWidth == undefined || docHeight == undefined) && typeof doc.attr.viewBox == 'string') {
|
|
42
|
-
var viewBoxParts = doc.attr.viewBox.split(/[,\s]+/);
|
|
43
|
-
if (viewBoxParts.length !== 4) {
|
|
44
|
-
throw new Error("Unexpected svg viewbox format, should have 4 entries but found: '" + doc.attr.viewBox + "'");
|
|
45
|
-
}
|
|
46
|
-
if (docWidth == undefined) {
|
|
47
|
-
docWidth = stripUnits(viewBoxParts[2]);
|
|
48
|
-
}
|
|
49
|
-
if (docHeight == undefined) {
|
|
50
|
-
docHeight = stripUnits(viewBoxParts[3]);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
width: docWidth,
|
|
56
|
-
height: docHeight
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
SVGMeasure.prototype.writeDimensions = function (svgString, dimensions) {
|
|
61
|
-
|
|
62
|
-
var doc = parseSVG(svgString);
|
|
63
|
-
|
|
64
|
-
doc.attr.width = "" + dimensions.width;
|
|
65
|
-
doc.attr.height = "" + dimensions.height;
|
|
66
|
-
|
|
67
|
-
return doc.toString();
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
module.exports = SVGMeasure;
|