@flowaccount/pdfmake 1.0.5 → 1.0.6-staging.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.
@@ -1,54 +1,54 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- '4A0': [4767.87, 6740.79],
5
- '2A0': [3370.39, 4767.87],
6
- A0: [2383.94, 3370.39],
7
- A1: [1683.78, 2383.94],
8
- A2: [1190.55, 1683.78],
9
- A3: [841.89, 1190.55],
10
- A4: [595.28, 841.89],
11
- A5: [419.53, 595.28],
12
- A6: [297.64, 419.53],
13
- A7: [209.76, 297.64],
14
- A8: [147.40, 209.76],
15
- A9: [104.88, 147.40],
16
- A10: [73.70, 104.88],
17
- B0: [2834.65, 4008.19],
18
- B1: [2004.09, 2834.65],
19
- B2: [1417.32, 2004.09],
20
- B3: [1000.63, 1417.32],
21
- B4: [708.66, 1000.63],
22
- B5: [498.90, 708.66],
23
- B6: [354.33, 498.90],
24
- B7: [249.45, 354.33],
25
- B8: [175.75, 249.45],
26
- B9: [124.72, 175.75],
27
- B10: [87.87, 124.72],
28
- C0: [2599.37, 3676.54],
29
- C1: [1836.85, 2599.37],
30
- C2: [1298.27, 1836.85],
31
- C3: [918.43, 1298.27],
32
- C4: [649.13, 918.43],
33
- C5: [459.21, 649.13],
34
- C6: [323.15, 459.21],
35
- C7: [229.61, 323.15],
36
- C8: [161.57, 229.61],
37
- C9: [113.39, 161.57],
38
- C10: [79.37, 113.39],
39
- RA0: [2437.80, 3458.27],
40
- RA1: [1729.13, 2437.80],
41
- RA2: [1218.90, 1729.13],
42
- RA3: [864.57, 1218.90],
43
- RA4: [609.45, 864.57],
44
- SRA0: [2551.18, 3628.35],
45
- SRA1: [1814.17, 2551.18],
46
- SRA2: [1275.59, 1814.17],
47
- SRA3: [907.09, 1275.59],
48
- SRA4: [637.80, 907.09],
49
- EXECUTIVE: [521.86, 756.00],
50
- FOLIO: [612.00, 936.00],
51
- LEGAL: [612.00, 1008.00],
52
- LETTER: [612.00, 792.00],
53
- TABLOID: [792.00, 1224.00]
54
- };
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ '4A0': [4767.87, 6740.79],
5
+ '2A0': [3370.39, 4767.87],
6
+ A0: [2383.94, 3370.39],
7
+ A1: [1683.78, 2383.94],
8
+ A2: [1190.55, 1683.78],
9
+ A3: [841.89, 1190.55],
10
+ A4: [595.28, 841.89],
11
+ A5: [419.53, 595.28],
12
+ A6: [297.64, 419.53],
13
+ A7: [209.76, 297.64],
14
+ A8: [147.40, 209.76],
15
+ A9: [104.88, 147.40],
16
+ A10: [73.70, 104.88],
17
+ B0: [2834.65, 4008.19],
18
+ B1: [2004.09, 2834.65],
19
+ B2: [1417.32, 2004.09],
20
+ B3: [1000.63, 1417.32],
21
+ B4: [708.66, 1000.63],
22
+ B5: [498.90, 708.66],
23
+ B6: [354.33, 498.90],
24
+ B7: [249.45, 354.33],
25
+ B8: [175.75, 249.45],
26
+ B9: [124.72, 175.75],
27
+ B10: [87.87, 124.72],
28
+ C0: [2599.37, 3676.54],
29
+ C1: [1836.85, 2599.37],
30
+ C2: [1298.27, 1836.85],
31
+ C3: [918.43, 1298.27],
32
+ C4: [649.13, 918.43],
33
+ C5: [459.21, 649.13],
34
+ C6: [323.15, 459.21],
35
+ C7: [229.61, 323.15],
36
+ C8: [161.57, 229.61],
37
+ C9: [113.39, 161.57],
38
+ C10: [79.37, 113.39],
39
+ RA0: [2437.80, 3458.27],
40
+ RA1: [1729.13, 2437.80],
41
+ RA2: [1218.90, 1729.13],
42
+ RA3: [864.57, 1218.90],
43
+ RA4: [609.45, 864.57],
44
+ SRA0: [2551.18, 3628.35],
45
+ SRA1: [1814.17, 2551.18],
46
+ SRA2: [1275.59, 1814.17],
47
+ SRA3: [907.09, 1275.59],
48
+ SRA4: [637.80, 907.09],
49
+ EXECUTIVE: [521.86, 756.00],
50
+ FOLIO: [612.00, 936.00],
51
+ LEGAL: [612.00, 1008.00],
52
+ LETTER: [612.00, 792.00],
53
+ TABLOID: [792.00, 1224.00]
54
+ };
@@ -1,138 +1,138 @@
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
- // rather than spend significant time making a styleOverrideObject, just add item
88
- this.push(item);
89
- return styleNames.length + 1;
90
- };
91
-
92
- /**
93
- * Automatically pushes elements onto the stack, using autopush based on item,
94
- * executes callback and then pops elements back. Returns value returned by callback
95
- *
96
- * @param {Object} item - an object with optional style property and/or style overrides
97
- * @param {Function} function to be called between autopush and pop
98
- * @return {Object} value returned by callback
99
- */
100
- StyleContextStack.prototype.auto = function (item, callback) {
101
- var pushedItems = this.autopush(item);
102
- var result = callback();
103
-
104
- if (pushedItems > 0) {
105
- this.pop(pushedItems);
106
- }
107
-
108
- return result;
109
- };
110
-
111
- /**
112
- * Evaluates stack and returns value of a named property
113
- *
114
- * @param {String} property - property name
115
- * @return property value or null if not found
116
- */
117
- StyleContextStack.prototype.getProperty = function (property) {
118
- if (this.styleOverrides) {
119
- for (var i = this.styleOverrides.length - 1; i >= 0; i--) {
120
- var item = this.styleOverrides[i];
121
-
122
- if (isString(item)) {
123
- // named-style-override
124
- var style = this.styleDictionary[item];
125
- if (style && !isUndefined(style[property]) && !isNull(style[property])) {
126
- return style[property];
127
- }
128
- } else if (!isUndefined(item[property]) && !isNull(item[property])) {
129
- // style-overrides-object
130
- return item[property];
131
- }
132
- }
133
- }
134
-
135
- return this.defaultStyle && this.defaultStyle[property];
136
- };
137
-
138
- module.exports = StyleContextStack;
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
+ // rather than spend significant time making a styleOverrideObject, just add item
88
+ this.push(item);
89
+ return styleNames.length + 1;
90
+ };
91
+
92
+ /**
93
+ * Automatically pushes elements onto the stack, using autopush based on item,
94
+ * executes callback and then pops elements back. Returns value returned by callback
95
+ *
96
+ * @param {Object} item - an object with optional style property and/or style overrides
97
+ * @param {Function} function to be called between autopush and pop
98
+ * @return {Object} value returned by callback
99
+ */
100
+ StyleContextStack.prototype.auto = function (item, callback) {
101
+ var pushedItems = this.autopush(item);
102
+ var result = callback();
103
+
104
+ if (pushedItems > 0) {
105
+ this.pop(pushedItems);
106
+ }
107
+
108
+ return result;
109
+ };
110
+
111
+ /**
112
+ * Evaluates stack and returns value of a named property
113
+ *
114
+ * @param {String} property - property name
115
+ * @return property value or null if not found
116
+ */
117
+ StyleContextStack.prototype.getProperty = function (property) {
118
+ if (this.styleOverrides) {
119
+ for (var i = this.styleOverrides.length - 1; i >= 0; i--) {
120
+ var item = this.styleOverrides[i];
121
+
122
+ if (isString(item)) {
123
+ // named-style-override
124
+ var style = this.styleDictionary[item];
125
+ if (style && !isUndefined(style[property]) && !isNull(style[property])) {
126
+ return style[property];
127
+ }
128
+ } else if (!isUndefined(item[property]) && !isNull(item[property])) {
129
+ // style-overrides-object
130
+ return item[property];
131
+ }
132
+ }
133
+ }
134
+
135
+ return this.defaultStyle && this.defaultStyle[property];
136
+ };
137
+
138
+ module.exports = StyleContextStack;
package/src/svgMeasure.js CHANGED
@@ -1,70 +1,70 @@
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;
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;