pdfmake 0.3.0-beta.6 → 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 (55) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +1 -1
  3. package/build/pdfmake.js +36523 -36424
  4. package/build/pdfmake.js.map +1 -1
  5. package/build/pdfmake.min.js +2 -2
  6. package/build/pdfmake.min.js.map +1 -1
  7. package/package.json +21 -20
  8. package/src/DocMeasure.js +3 -0
  9. package/src/Printer.js +1 -0
  10. package/src/TableProcessor.js +4 -0
  11. package/src/TextDecorator.js +1 -1
  12. package/src/qrEnc.js +5 -3
  13. package/js/3rd-party/svg-to-pdfkit/source.js +0 -3628
  14. package/js/3rd-party/svg-to-pdfkit.js +0 -7
  15. package/js/DocMeasure.js +0 -624
  16. package/js/DocPreprocessor.js +0 -238
  17. package/js/DocumentContext.js +0 -265
  18. package/js/ElementWriter.js +0 -331
  19. package/js/LayoutBuilder.js +0 -694
  20. package/js/Line.js +0 -105
  21. package/js/OutputDocument.js +0 -76
  22. package/js/OutputDocumentServer.js +0 -27
  23. package/js/PDFDocument.js +0 -144
  24. package/js/PageElementWriter.js +0 -140
  25. package/js/PageSize.js +0 -74
  26. package/js/Printer.js +0 -290
  27. package/js/Renderer.js +0 -375
  28. package/js/SVGMeasure.js +0 -69
  29. package/js/StyleContextStack.js +0 -181
  30. package/js/TableProcessor.js +0 -508
  31. package/js/TextBreaker.js +0 -139
  32. package/js/TextDecorator.js +0 -143
  33. package/js/TextInlines.js +0 -206
  34. package/js/URLResolver.js +0 -73
  35. package/js/base.js +0 -52
  36. package/js/browser-extensions/OutputDocumentBrowser.js +0 -118
  37. package/js/browser-extensions/URLBrowserResolver.js +0 -76
  38. package/js/browser-extensions/fonts/Roboto.js +0 -38
  39. package/js/browser-extensions/index.js +0 -53
  40. package/js/browser-extensions/pdfMake.js +0 -15
  41. package/js/browser-extensions/standard-fonts/Courier.js +0 -38
  42. package/js/browser-extensions/standard-fonts/Helvetica.js +0 -38
  43. package/js/browser-extensions/standard-fonts/Symbol.js +0 -23
  44. package/js/browser-extensions/standard-fonts/Times.js +0 -38
  45. package/js/browser-extensions/standard-fonts/ZapfDingbats.js +0 -23
  46. package/js/browser-extensions/virtual-fs-cjs.js +0 -3
  47. package/js/columnCalculator.js +0 -129
  48. package/js/helpers/node.js +0 -98
  49. package/js/helpers/tools.js +0 -40
  50. package/js/helpers/variableType.js +0 -47
  51. package/js/index.js +0 -15
  52. package/js/qrEnc.js +0 -720
  53. package/js/standardPageSizes.js +0 -56
  54. package/js/tableLayouts.js +0 -98
  55. package/js/virtual-fs.js +0 -60
package/js/SVGMeasure.js DELETED
@@ -1,69 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _xmldoc = _interopRequireDefault(require("xmldoc"));
6
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
- /**
8
- * Strip unit postfix, parse number, but return undefined instead of NaN for bad input
9
- *
10
- * @param {string} textVal
11
- * @returns {?number}
12
- */
13
- const stripUnits = textVal => {
14
- var n = parseFloat(textVal);
15
- if (typeof n !== 'number' || isNaN(n)) {
16
- return undefined;
17
- }
18
- return n;
19
- };
20
-
21
- /**
22
- * Make sure it's valid XML and the root tage is <svg/>, returns xmldoc DOM
23
- *
24
- * @param {string} svgString
25
- * @returns {object}
26
- */
27
- const parseSVG = svgString => {
28
- var doc;
29
- try {
30
- doc = new _xmldoc.default.XmlDocument(svgString);
31
- } catch (err) {
32
- throw new Error('SVGMeasure: ' + err);
33
- }
34
- if (doc.name !== "svg") {
35
- throw new Error('SVGMeasure: expected <svg> document');
36
- }
37
- return doc;
38
- };
39
- class SVGMeasure {
40
- constructor() {}
41
- measureSVG(svgString) {
42
- let doc = parseSVG(svgString);
43
- let docWidth = stripUnits(doc.attr.width);
44
- let docHeight = stripUnits(doc.attr.height);
45
- if ((docWidth === undefined || docHeight === undefined) && typeof doc.attr.viewBox === 'string') {
46
- let viewBoxParts = doc.attr.viewBox.split(/[,\s]+/);
47
- if (viewBoxParts.length !== 4) {
48
- throw new Error("Unexpected svg viewbox format, should have 4 entries but found: '" + doc.attr.viewBox + "'");
49
- }
50
- if (docWidth === undefined) {
51
- docWidth = stripUnits(viewBoxParts[2]);
52
- }
53
- if (docHeight === undefined) {
54
- docHeight = stripUnits(viewBoxParts[3]);
55
- }
56
- }
57
- return {
58
- width: docWidth,
59
- height: docHeight
60
- };
61
- }
62
- writeDimensions(svgString, dimensions) {
63
- let doc = parseSVG(svgString);
64
- doc.attr.width = "" + dimensions.width;
65
- doc.attr.height = "" + dimensions.height;
66
- return doc.toString();
67
- }
68
- }
69
- var _default = exports.default = SVGMeasure;
@@ -1,181 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _variableType = require("./helpers/variableType");
6
- /**
7
- * Used for style inheritance and style overrides
8
- */
9
- class StyleContextStack {
10
- /**
11
- * @param {object} styleDictionary named styles dictionary
12
- * @param {object} defaultStyle optional default style definition
13
- */
14
- constructor(styleDictionary, defaultStyle = {}) {
15
- this.styleDictionary = styleDictionary;
16
- this.defaultStyle = defaultStyle;
17
- this.styleOverrides = [];
18
- }
19
-
20
- /**
21
- * Creates cloned version of current stack
22
- *
23
- * @returns {StyleContextStack} current stack snapshot
24
- */
25
- clone() {
26
- let stack = new StyleContextStack(this.styleDictionary, this.defaultStyle);
27
- this.styleOverrides.forEach(item => {
28
- stack.styleOverrides.push(item);
29
- });
30
- return stack;
31
- }
32
-
33
- /**
34
- * Pushes style-name or style-overrides-object onto the stack for future evaluation
35
- *
36
- * @param {string|object} styleNameOrOverride style-name (referring to styleDictionary) or
37
- * a new dictionary defining overriding properties
38
- */
39
- push(styleNameOrOverride) {
40
- this.styleOverrides.push(styleNameOrOverride);
41
- }
42
-
43
- /**
44
- * Removes last style-name or style-overrides-object from the stack
45
- *
46
- * @param {number} howMany optional number of elements to be popped (if not specified,
47
- * one element will be removed from the stack)
48
- */
49
- pop(howMany = 1) {
50
- while (howMany-- > 0) {
51
- this.styleOverrides.pop();
52
- }
53
- }
54
-
55
- /**
56
- * Creates a set of named styles or/and a style-overrides-object based on the item,
57
- * pushes those elements onto the stack for future evaluation and returns the number
58
- * of elements pushed, so they can be easily poped then.
59
- *
60
- * @param {object} item - an object with optional style property and/or style overrides
61
- * @returns {number} the number of items pushed onto the stack
62
- */
63
- autopush(item) {
64
- if ((0, _variableType.isString)(item)) {
65
- return 0;
66
- }
67
- let styleNames = [];
68
- if (item.style) {
69
- if (Array.isArray(item.style)) {
70
- styleNames = item.style;
71
- } else {
72
- styleNames = [item.style];
73
- }
74
- }
75
- for (let i = 0, l = styleNames.length; i < l; i++) {
76
- this.push(styleNames[i]);
77
- }
78
- let styleProperties = ['font', 'fontSize', 'fontFeatures', 'bold', 'italics', 'alignment', 'color', 'columnGap', 'fillColor', 'fillOpacity', 'decoration', 'decorationStyle', 'decorationColor', 'background', 'lineHeight', 'characterSpacing', 'noWrap', 'markerColor', 'leadingIndent', 'sup', 'sub'
79
- //'tableCellPadding'
80
- // 'cellBorder',
81
- // 'headerCellBorder',
82
- // 'oddRowCellBorder',
83
- // 'evenRowCellBorder',
84
- // 'tableBorder'
85
- ];
86
-
87
- let styleOverrideObject = {};
88
- let pushStyleOverrideObject = false;
89
- styleProperties.forEach(key => {
90
- if ((0, _variableType.isValue)(item[key])) {
91
- styleOverrideObject[key] = item[key];
92
- pushStyleOverrideObject = true;
93
- }
94
- });
95
- if (pushStyleOverrideObject) {
96
- this.push(styleOverrideObject);
97
- }
98
- return styleNames.length + (pushStyleOverrideObject ? 1 : 0);
99
- }
100
-
101
- /**
102
- * Automatically pushes elements onto the stack, using autopush based on item,
103
- * executes callback and then pops elements back. Returns value returned by callback
104
- *
105
- * @param {object} item - an object with optional style property and/or style overrides
106
- * @param {Function} callback to be called between autopush and pop
107
- * @returns {object} value returned by callback
108
- */
109
- auto(item, callback) {
110
- let pushedItems = this.autopush(item);
111
- let result = callback();
112
- if (pushedItems > 0) {
113
- this.pop(pushedItems);
114
- }
115
- return result;
116
- }
117
-
118
- /**
119
- * Evaluates stack and returns value of a named property
120
- *
121
- * @param {string} property - property name
122
- * @returns {?any} property value or null if not found
123
- */
124
- getProperty(property) {
125
- if (this.styleOverrides) {
126
- for (let i = this.styleOverrides.length - 1; i >= 0; i--) {
127
- let item = this.styleOverrides[i];
128
- if ((0, _variableType.isString)(item)) {
129
- // named-style-override
130
- let style = this.styleDictionary[item];
131
- if (style && (0, _variableType.isValue)(style[property])) {
132
- return style[property];
133
- }
134
- } else if ((0, _variableType.isValue)(item[property])) {
135
- // style-overrides-object
136
- return item[property];
137
- }
138
- }
139
- }
140
- return this.defaultStyle && this.defaultStyle[property];
141
- }
142
-
143
- /**
144
- * @param {object} item
145
- * @param {StyleContextStack} styleContextStack
146
- * @param {string} property
147
- * @param {any} defaultValue
148
- * @returns {any}
149
- */
150
- static getStyleProperty(item, styleContextStack, property, defaultValue) {
151
- let value;
152
- if ((0, _variableType.isValue)(item[property])) {
153
- // item defines this property
154
- return item[property];
155
- }
156
- if (!styleContextStack) {
157
- return defaultValue;
158
- }
159
- styleContextStack.auto(item, () => {
160
- value = styleContextStack.getProperty(property);
161
- });
162
- return (0, _variableType.isValue)(value) ? value : defaultValue;
163
- }
164
-
165
- /**
166
- * @param {object} source
167
- * @param {object} destination
168
- * @returns {object}
169
- */
170
- static copyStyle(source = {}, destination = {}) {
171
- // TODO: default style to source
172
-
173
- for (let key in source) {
174
- if (key != 'text' && source.hasOwnProperty(key)) {
175
- destination[key] = source[key];
176
- }
177
- }
178
- return destination;
179
- }
180
- }
181
- var _default = exports.default = StyleContextStack;