pdfmake 0.2.4 → 0.3.0-beta.1

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 (128) hide show
  1. package/CHANGELOG.md +8 -30
  2. package/README.md +8 -6
  3. package/build/pdfmake.js +28921 -26825
  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/build/standard-fonts/Courier.js +27 -0
  8. package/build/standard-fonts/Helvetica.js +27 -0
  9. package/build/standard-fonts/Symbol.js +21 -0
  10. package/build/standard-fonts/Times.js +27 -0
  11. package/build/standard-fonts/ZapfDingbats.js +21 -0
  12. package/build/vfs_fonts.js +2 -2
  13. package/build-vfs.js +2 -2
  14. package/fonts/Roboto/Roboto-Italic.ttf +0 -0
  15. package/fonts/Roboto/Roboto-Medium.ttf +0 -0
  16. package/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  17. package/fonts/Roboto/Roboto-Regular.ttf +0 -0
  18. package/fonts/Roboto.js +8 -0
  19. package/js/3rd-party/svg-to-pdfkit/source.js +4301 -0
  20. package/js/3rd-party/svg-to-pdfkit.js +11 -0
  21. package/js/DocMeasure.js +750 -0
  22. package/js/DocPreprocessor.js +285 -0
  23. package/js/DocumentContext.js +306 -0
  24. package/js/ElementWriter.js +377 -0
  25. package/js/LayoutBuilder.js +833 -0
  26. package/js/Line.js +125 -0
  27. package/js/OutputDocument.js +86 -0
  28. package/js/OutputDocumentServer.js +34 -0
  29. package/js/PDFDocument.js +163 -0
  30. package/js/PageElementWriter.js +161 -0
  31. package/js/PageSize.js +88 -0
  32. package/js/Printer.js +238 -0
  33. package/js/Renderer.js +433 -0
  34. package/js/SVGMeasure.js +89 -0
  35. package/js/StyleContextStack.js +206 -0
  36. package/js/TableProcessor.js +590 -0
  37. package/js/TextBreaker.js +182 -0
  38. package/js/TextDecorator.js +181 -0
  39. package/js/TextInlines.js +248 -0
  40. package/js/URLResolver.js +79 -0
  41. package/js/base.js +69 -0
  42. package/js/browser-extensions/OutputDocumentBrowser.js +131 -0
  43. package/js/browser-extensions/URLBrowserResolver.js +89 -0
  44. package/js/browser-extensions/fonts/Roboto.js +42 -0
  45. package/js/browser-extensions/index.js +70 -0
  46. package/js/browser-extensions/pdfMake.js +17 -0
  47. package/js/browser-extensions/standard-fonts/Courier.js +42 -0
  48. package/js/browser-extensions/standard-fonts/Helvetica.js +42 -0
  49. package/js/browser-extensions/standard-fonts/Symbol.js +27 -0
  50. package/js/browser-extensions/standard-fonts/Times.js +42 -0
  51. package/js/browser-extensions/standard-fonts/ZapfDingbats.js +27 -0
  52. package/js/browser-extensions/virtual-fs-cjs.js +3 -0
  53. package/js/columnCalculator.js +142 -0
  54. package/js/helpers/node.js +122 -0
  55. package/js/helpers/tools.js +48 -0
  56. package/js/helpers/variableType.js +52 -0
  57. package/js/index.js +21 -0
  58. package/js/qrEnc.js +810 -0
  59. package/js/standardPageSizes.js +57 -0
  60. package/js/tableLayouts.js +127 -0
  61. package/js/virtual-fs.js +77 -0
  62. package/package.json +26 -22
  63. package/src/3rd-party/svg-to-pdfkit.js +2 -2
  64. package/src/DocMeasure.js +694 -0
  65. package/src/DocPreprocessor.js +258 -0
  66. package/src/DocumentContext.js +309 -0
  67. package/src/ElementWriter.js +368 -0
  68. package/src/LayoutBuilder.js +814 -0
  69. package/src/Line.js +114 -0
  70. package/src/OutputDocument.js +78 -0
  71. package/src/OutputDocumentServer.js +26 -0
  72. package/src/PDFDocument.js +148 -0
  73. package/src/PageElementWriter.js +156 -0
  74. package/src/PageSize.js +53 -0
  75. package/src/Printer.js +220 -0
  76. package/src/Renderer.js +370 -0
  77. package/src/SVGMeasure.js +79 -0
  78. package/src/StyleContextStack.js +216 -0
  79. package/src/TableProcessor.js +558 -0
  80. package/src/TextBreaker.js +149 -0
  81. package/src/TextDecorator.js +161 -0
  82. package/src/TextInlines.js +223 -0
  83. package/src/URLResolver.js +69 -0
  84. package/src/base.js +61 -0
  85. package/src/browser-extensions/OutputDocumentBrowser.js +117 -0
  86. package/src/browser-extensions/URLBrowserResolver.js +46 -53
  87. package/src/browser-extensions/fonts/Roboto.js +27 -0
  88. package/src/browser-extensions/index.js +55 -0
  89. package/src/browser-extensions/pdfMake.js +10 -282
  90. package/src/browser-extensions/standard-fonts/Courier.js +27 -0
  91. package/src/browser-extensions/standard-fonts/Helvetica.js +27 -0
  92. package/src/browser-extensions/standard-fonts/Symbol.js +21 -0
  93. package/src/browser-extensions/standard-fonts/Times.js +27 -0
  94. package/src/browser-extensions/standard-fonts/ZapfDingbats.js +21 -0
  95. package/src/browser-extensions/virtual-fs-cjs.js +1 -0
  96. package/src/columnCalculator.js +29 -32
  97. package/src/helpers/node.js +110 -0
  98. package/src/helpers/tools.js +39 -0
  99. package/src/helpers/variableType.js +39 -0
  100. package/src/index.js +16 -0
  101. package/src/qrEnc.js +15 -10
  102. package/src/standardPageSizes.js +1 -3
  103. package/src/tableLayouts.js +100 -0
  104. package/src/virtual-fs.js +66 -0
  105. package/standard-fonts/Courier.js +8 -0
  106. package/standard-fonts/Helvetica.js +9 -0
  107. package/standard-fonts/Symbol.js +5 -0
  108. package/standard-fonts/Times.js +8 -0
  109. package/standard-fonts/ZapfDingbats.js +5 -0
  110. package/src/browser-extensions/virtual-fs.js +0 -55
  111. package/src/docMeasure.js +0 -807
  112. package/src/docPreprocessor.js +0 -255
  113. package/src/documentContext.js +0 -314
  114. package/src/elementWriter.js +0 -322
  115. package/src/fontProvider.js +0 -68
  116. package/src/helpers.js +0 -126
  117. package/src/imageMeasure.js +0 -51
  118. package/src/layoutBuilder.js +0 -807
  119. package/src/line.js +0 -91
  120. package/src/pageElementWriter.js +0 -174
  121. package/src/pdfKitEngine.js +0 -21
  122. package/src/printer.js +0 -705
  123. package/src/styleContextStack.js +0 -179
  124. package/src/svgMeasure.js +0 -70
  125. package/src/tableProcessor.js +0 -561
  126. package/src/textDecorator.js +0 -157
  127. package/src/textTools.js +0 -373
  128. package/src/traversalTracker.js +0 -47
@@ -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;