pdfmake 0.2.1 → 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 (130) hide show
  1. package/CHANGELOG.md +8 -14
  2. package/README.md +8 -6
  3. package/build/pdfmake.js +31416 -28217
  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 +3 -3
  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 +31 -25
  63. package/src/3rd-party/svg-to-pdfkit/LICENSE +9 -0
  64. package/src/3rd-party/svg-to-pdfkit/source.js +2552 -0
  65. package/src/3rd-party/svg-to-pdfkit.js +3 -0
  66. package/src/DocMeasure.js +694 -0
  67. package/src/DocPreprocessor.js +258 -0
  68. package/src/DocumentContext.js +309 -0
  69. package/src/ElementWriter.js +368 -0
  70. package/src/LayoutBuilder.js +814 -0
  71. package/src/Line.js +114 -0
  72. package/src/OutputDocument.js +78 -0
  73. package/src/OutputDocumentServer.js +26 -0
  74. package/src/PDFDocument.js +148 -0
  75. package/src/PageElementWriter.js +156 -0
  76. package/src/PageSize.js +53 -0
  77. package/src/Printer.js +220 -0
  78. package/src/Renderer.js +370 -0
  79. package/src/SVGMeasure.js +79 -0
  80. package/src/StyleContextStack.js +216 -0
  81. package/src/TableProcessor.js +558 -0
  82. package/src/TextBreaker.js +149 -0
  83. package/src/TextDecorator.js +161 -0
  84. package/src/TextInlines.js +223 -0
  85. package/src/URLResolver.js +69 -0
  86. package/src/base.js +61 -0
  87. package/src/browser-extensions/OutputDocumentBrowser.js +117 -0
  88. package/src/browser-extensions/URLBrowserResolver.js +46 -53
  89. package/src/browser-extensions/fonts/Roboto.js +27 -0
  90. package/src/browser-extensions/index.js +55 -0
  91. package/src/browser-extensions/pdfMake.js +10 -287
  92. package/src/browser-extensions/standard-fonts/Courier.js +27 -0
  93. package/src/browser-extensions/standard-fonts/Helvetica.js +27 -0
  94. package/src/browser-extensions/standard-fonts/Symbol.js +21 -0
  95. package/src/browser-extensions/standard-fonts/Times.js +27 -0
  96. package/src/browser-extensions/standard-fonts/ZapfDingbats.js +21 -0
  97. package/src/browser-extensions/virtual-fs-cjs.js +1 -0
  98. package/src/columnCalculator.js +29 -32
  99. package/src/helpers/node.js +110 -0
  100. package/src/helpers/tools.js +39 -0
  101. package/src/helpers/variableType.js +39 -0
  102. package/src/index.js +16 -0
  103. package/src/qrEnc.js +15 -10
  104. package/src/standardPageSizes.js +1 -3
  105. package/src/tableLayouts.js +100 -0
  106. package/src/virtual-fs.js +66 -0
  107. package/standard-fonts/Courier.js +8 -0
  108. package/standard-fonts/Helvetica.js +9 -0
  109. package/standard-fonts/Symbol.js +5 -0
  110. package/standard-fonts/Times.js +8 -0
  111. package/standard-fonts/ZapfDingbats.js +5 -0
  112. package/src/browser-extensions/virtual-fs.js +0 -55
  113. package/src/docMeasure.js +0 -807
  114. package/src/docPreprocessor.js +0 -255
  115. package/src/documentContext.js +0 -314
  116. package/src/elementWriter.js +0 -322
  117. package/src/fontProvider.js +0 -68
  118. package/src/helpers.js +0 -113
  119. package/src/imageMeasure.js +0 -51
  120. package/src/layoutBuilder.js +0 -807
  121. package/src/line.js +0 -91
  122. package/src/pageElementWriter.js +0 -174
  123. package/src/pdfKitEngine.js +0 -21
  124. package/src/printer.js +0 -685
  125. package/src/styleContextStack.js +0 -179
  126. package/src/svgMeasure.js +0 -70
  127. package/src/tableProcessor.js +0 -542
  128. package/src/textDecorator.js +0 -151
  129. package/src/textTools.js +0 -373
  130. package/src/traversalTracker.js +0 -47
@@ -1,46 +1,38 @@
1
- 'use strict';
2
-
3
- // Internet Explorer polyfills
4
- if (typeof window !== 'undefined' && !window.Promise) {
5
- require('core-js/features/promise');
6
- }
7
- require('core-js/es/object/values');
8
-
9
- var fetchUrl = function (url) {
10
- return new Promise(function (resolve, reject) {
11
- var xhr = new XMLHttpRequest();
1
+ const fetchUrl = url => {
2
+ return new Promise((resolve, reject) => {
3
+ const xhr = new XMLHttpRequest();
12
4
  xhr.open('GET', url, true);
13
5
  xhr.responseType = 'arraybuffer';
14
6
 
15
- xhr.onreadystatechange = function () {
7
+ xhr.onreadystatechange = () => {
16
8
  if (xhr.readyState !== 4) {
17
9
  return;
18
10
  }
19
11
 
20
- var ok = xhr.status >= 200 && xhr.status < 300;
12
+ const ok = xhr.status >= 200 && xhr.status < 300;
21
13
  if (!ok) {
22
- setTimeout(function () {
23
- reject(new TypeError('Failed to fetch (url: "' + url + '")'));
14
+ setTimeout(() => {
15
+ reject(new TypeError(`Failed to fetch (url: "${url}")`));
24
16
  }, 0);
25
17
  }
26
18
  };
27
19
 
28
- xhr.onload = function () {
29
- var ok = xhr.status >= 200 && xhr.status < 300;
20
+ xhr.onload = () => {
21
+ const ok = xhr.status >= 200 && xhr.status < 300;
30
22
  if (ok) {
31
23
  resolve(xhr.response);
32
24
  }
33
25
  };
34
26
 
35
- xhr.onerror = function () {
36
- setTimeout(function () {
37
- reject(new TypeError('Network request failed (url: "' + url + '")'));
27
+ xhr.onerror = () => {
28
+ setTimeout(() => {
29
+ reject(new TypeError(`Network request failed (url: "${url}")`));
38
30
  }, 0);
39
31
  };
40
32
 
41
- xhr.ontimeout = function () {
42
- setTimeout(function () {
43
- reject(new TypeError('Network request failed (url: "' + url + '")'));
33
+ xhr.ontimeout = () => {
34
+ setTimeout(() => {
35
+ reject(new TypeError(`Network request failed (url: "${url}")`));
44
36
  }, 0);
45
37
  };
46
38
 
@@ -48,41 +40,42 @@ var fetchUrl = function (url) {
48
40
  });
49
41
  };
50
42
 
51
- function URLBrowserResolver(fs) {
52
- this.fs = fs;
53
- this.resolving = {};
54
- }
43
+ class URLBrowserResolver {
44
+ constructor(fs) {
45
+ this.fs = fs;
46
+ this.resolving = {};
47
+ }
55
48
 
56
- URLBrowserResolver.prototype.resolve = function (url) {
57
- if (!this.resolving[url]) {
58
- var _this = this;
59
- this.resolving[url] = new Promise(function (resolve, reject) {
60
- if (url.toLowerCase().indexOf('https://') === 0 || url.toLowerCase().indexOf('http://') === 0) {
61
- fetchUrl(url).then(function (buffer) {
62
- _this.fs.writeFileSync(url, buffer);
49
+ resolve(url) {
50
+ if (!this.resolving[url]) {
51
+ this.resolving[url] = new Promise((resolve, reject) => {
52
+ if (url.toLowerCase().indexOf('https://') === 0 || url.toLowerCase().indexOf('http://') === 0) {
53
+ fetchUrl(url).then(buffer => {
54
+ this.fs.writeFileSync(url, buffer);
55
+ resolve();
56
+ }, result => {
57
+ reject(result);
58
+ });
59
+ } else {
60
+ // cannot be resolved
63
61
  resolve();
64
- }, function (result) {
65
- reject(result);
66
- });
67
- } else {
68
- // cannot be resolved
62
+ }
63
+ });
64
+ }
65
+
66
+ return this.resolving[url];
67
+ }
68
+
69
+ resolved() {
70
+ return new Promise((resolve, reject) => {
71
+ Promise.all(Object.values(this.resolving)).then(() => {
69
72
  resolve();
70
- }
73
+ }, result => {
74
+ reject(result);
75
+ });
71
76
  });
72
77
  }
73
78
 
74
- return this.resolving[url];
75
- }
76
-
77
- URLBrowserResolver.prototype.resolved = function () {
78
- var _this = this;
79
- return new Promise(function (resolve, reject) {
80
- Promise.all(Object.values(_this.resolving)).then(function () {
81
- resolve();
82
- }, function (result) {
83
- reject(result);
84
- });
85
- });
86
79
  }
87
80
 
88
- module.exports = URLBrowserResolver;
81
+ export default URLBrowserResolver;
@@ -0,0 +1,27 @@
1
+ var fs = require('fs');
2
+
3
+ var fontContainer = {
4
+ vfs: {
5
+ 'Roboto-Regular.ttf': { data: fs.readFileSync(__dirname + '/../../../fonts/Roboto/Roboto-Regular.ttf', 'base64'), encoding: 'base64' },
6
+ 'Roboto-Medium.ttf': { data: fs.readFileSync(__dirname + '/../../../fonts/Roboto/Roboto-Medium.ttf', 'base64'), encoding: 'base64' },
7
+ 'Roboto-Italic.ttf': { data: fs.readFileSync(__dirname + '/../../../fonts/Roboto/Roboto-Italic.ttf', 'base64'), encoding: 'base64' },
8
+ 'Roboto-MediumItalic.ttf': { data: fs.readFileSync(__dirname + '/../../../fonts/Roboto/Roboto-MediumItalic.ttf', 'base64'), encoding: 'base64' }
9
+ },
10
+ fonts: {
11
+ Roboto: {
12
+ normal: 'Roboto-Regular.ttf',
13
+ bold: 'Roboto-Medium.ttf',
14
+ italics: 'Roboto-Italic.ttf',
15
+ bolditalics: 'Roboto-MediumItalic.ttf'
16
+ }
17
+ }
18
+ };
19
+
20
+ var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this;
21
+ if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
22
+ _global.pdfMake.addFontContainer(fontContainer);
23
+ }
24
+
25
+ if (typeof module !== 'undefined') {
26
+ module.exports = fontContainer;
27
+ }
@@ -0,0 +1,55 @@
1
+ import pdfmakeBase from '../base';
2
+ import OutputDocumentBrowser from './OutputDocumentBrowser';
3
+ import URLBrowserResolver from './URLBrowserResolver';
4
+ import fs from 'fs';
5
+ import configurator from 'core-js/configurator';
6
+
7
+ // core-js: Polyfills will be used only if natives completely unavailable.
8
+ configurator({
9
+ useNative: ['Promise']
10
+ });
11
+
12
+ let defaultClientFonts = {
13
+ Roboto: {
14
+ normal: 'Roboto-Regular.ttf',
15
+ bold: 'Roboto-Medium.ttf',
16
+ italics: 'Roboto-Italic.ttf',
17
+ bolditalics: 'Roboto-MediumItalic.ttf'
18
+ }
19
+ };
20
+
21
+ class pdfmake extends pdfmakeBase {
22
+ constructor() {
23
+ super();
24
+ this.urlResolver = new URLBrowserResolver(this.virtualfs);
25
+ this.fonts = defaultClientFonts;
26
+ }
27
+
28
+ addFontContainer(fontContainer) {
29
+ this.addVirtualFileSystem(fontContainer.vfs);
30
+ this.addFonts(fontContainer.fonts);
31
+ }
32
+
33
+ addVirtualFileSystem(vfs) {
34
+ for (let key in vfs) {
35
+ if (vfs.hasOwnProperty(key)) {
36
+ let data;
37
+ let encoding;
38
+ if (typeof vfs[key] === 'object') {
39
+ data = vfs[key].data;
40
+ encoding = vfs[key].encoding || 'base64';
41
+ } else {
42
+ data = vfs[key];
43
+ encoding = 'base64';
44
+ }
45
+ fs.writeFileSync(key, data, encoding);
46
+ }
47
+ }
48
+ }
49
+
50
+ _transformToDocument(doc) {
51
+ return new OutputDocumentBrowser(doc);
52
+ }
53
+ }
54
+
55
+ export default new pdfmake();
@@ -1,292 +1,15 @@
1
- 'use strict';
2
-
3
- var isFunction = require('../helpers').isFunction;
4
- var isUndefined = require('../helpers').isUndefined;
5
- var isNull = require('../helpers').isNull;
6
- var FileSaver = require('file-saver');
7
- var saveAs = FileSaver.saveAs;
8
-
9
- var defaultClientFonts = {
10
- Roboto: {
11
- normal: 'Roboto-Regular.ttf',
12
- bold: 'Roboto-Medium.ttf',
13
- italics: 'Roboto-Italic.ttf',
14
- bolditalics: 'Roboto-MediumItalic.ttf'
15
- }
16
- };
17
-
18
- function Document(docDefinition, tableLayouts, fonts, vfs) {
19
- this.docDefinition = docDefinition;
20
- this.tableLayouts = tableLayouts || null;
21
- this.fonts = fonts || defaultClientFonts;
22
- this.vfs = vfs;
23
- }
24
-
25
- function canCreatePdf() {
26
- // Ensure the browser provides the level of support needed
27
- try {
28
- var arr = new Uint8Array(1)
29
- var proto = { foo: function () { return 42 } }
30
- Object.setPrototypeOf(proto, Uint8Array.prototype)
31
- Object.setPrototypeOf(arr, proto)
32
- return arr.foo() === 42
33
- } catch (e) {
34
- return false
35
- }
36
-
37
- if (!Object.keys || typeof Uint16Array === 'undefined') {
38
- return false;
39
- }
40
- return true;
41
- }
42
-
43
- Document.prototype._createDoc = function (options, cb) {
44
- options = options || {};
45
- if (this.tableLayouts) {
46
- options.tableLayouts = this.tableLayouts;
47
- }
48
-
49
- var PdfPrinter = require('../printer');
50
-
51
- var printer = new PdfPrinter(this.fonts);
52
- require('fs').bindFS(this.vfs); // bind virtual file system to file system
53
-
54
- if (!isFunction(cb)) {
55
- var doc = printer.createPdfKitDocument(this.docDefinition, options);
56
-
57
- return doc;
1
+ const isBrowserSupported = () => {
2
+ if ((typeof window === 'undefined') || (typeof window.navigator === 'undefined')) {
3
+ // Enviroment is not browser.
4
+ return true;
58
5
  }
59
6
 
60
- var URLBrowserResolver = require('./URLBrowserResolver');
61
- var urlResolver = new URLBrowserResolver(require('fs'));
62
-
63
- for (var font in this.fonts) {
64
- if (this.fonts.hasOwnProperty(font)) {
65
- if (this.fonts[font].normal) {
66
- urlResolver.resolve(this.fonts[font].normal);
67
- }
68
- if (this.fonts[font].bold) {
69
- urlResolver.resolve(this.fonts[font].bold);
70
- }
71
- if (this.fonts[font].italics) {
72
- urlResolver.resolve(this.fonts[font].italics);
73
- }
74
- if (this.fonts[font].bolditalics) {
75
- urlResolver.resolve(this.fonts[font].bolditalics);
76
- }
77
- }
78
- }
79
-
80
- if (this.docDefinition.images) {
81
- for (var image in this.docDefinition.images) {
82
- if (this.docDefinition.images.hasOwnProperty(image)) {
83
- urlResolver.resolve(this.docDefinition.images[image]);
84
- }
85
- }
86
- }
87
-
88
- var _this = this;
89
-
90
- urlResolver.resolved().then(function () {
91
- var doc = printer.createPdfKitDocument(_this.docDefinition, options);
92
-
93
- cb(doc);
94
- }, function (result) {
95
- throw result;
96
- });
97
- };
98
-
99
- Document.prototype._flushDoc = function (doc, callback) {
100
- var chunks = [];
101
- var result;
102
-
103
- doc.on('readable', function () {
104
- var chunk;
105
- while ((chunk = doc.read(9007199254740991)) !== null) {
106
- chunks.push(chunk);
107
- }
108
- });
109
- doc.on('end', function () {
110
- result = Buffer.concat(chunks);
111
- callback(result, doc._pdfMakePages);
112
- });
113
- doc.end();
114
- };
115
-
116
- Document.prototype._getPages = function (options, cb) {
117
- if (!cb) {
118
- throw '_getPages is an async method and needs a callback argument';
119
- }
120
- var _this = this;
121
-
122
- this._createDoc(options, function (doc) {
123
- _this._flushDoc(doc, function (ignoreBuffer, pages) {
124
- cb(pages);
125
- });
126
- });
7
+ // Internet Explorer 10 and older is not supported.
8
+ return window.navigator.userAgent.indexOf("MSIE") === -1;
127
9
  };
128
10
 
129
- Document.prototype._bufferToBlob = function (buffer) {
130
- var blob;
131
- try {
132
- blob = new Blob([buffer], { type: 'application/pdf' });
133
- } catch (e) {
134
- // Old browser which can't handle it without making it an byte array (ie10)
135
- if (e.name === 'InvalidStateError') {
136
- var byteArray = new Uint8Array(buffer);
137
- blob = new Blob([byteArray.buffer], { type: 'application/pdf' });
138
- }
139
- }
140
-
141
- if (!blob) {
142
- throw 'Could not generate blob';
143
- }
144
-
145
- return blob;
146
- };
147
-
148
- Document.prototype._openWindow = function () {
149
- // we have to open the window immediately and store the reference
150
- // otherwise popup blockers will stop us
151
- var win = window.open('', '_blank');
152
- if (win === null) {
153
- throw 'Open PDF in new window blocked by browser';
154
- }
155
-
156
- return win;
157
- };
158
-
159
- Document.prototype._openPdf = function (options, win) {
160
- if (!win) {
161
- win = this._openWindow();
162
- }
163
- try {
164
- this.getBlob(function (result) {
165
- var urlCreator = window.URL || window.webkitURL;
166
- var pdfUrl = urlCreator.createObjectURL(result);
167
- win.location.href = pdfUrl;
168
-
169
- /* temporarily disabled
170
- if (win !== window) {
171
- setTimeout(function () {
172
- if (isNull(win.window)) { // is closed by AdBlock
173
- window.location.href = pdfUrl; // open in actual window
174
- }
175
- }, 500);
176
- }
177
- */
178
- }, options);
179
- } catch (e) {
180
- win.close();
181
- throw e;
182
- }
183
- };
184
-
185
- Document.prototype.open = function (options, win) {
186
- options = options || {};
187
- options.autoPrint = false;
188
- win = win || null;
189
-
190
- this._openPdf(options, win);
191
- };
192
-
193
-
194
- Document.prototype.print = function (options, win) {
195
- options = options || {};
196
- options.autoPrint = true;
197
- win = win || null;
198
-
199
- this._openPdf(options, win);
200
- };
201
-
202
- /**
203
- * download(defaultFileName = 'file.pdf', cb = null, options = {})
204
- * or
205
- * download(cb, options = {})
206
- */
207
- Document.prototype.download = function (defaultFileName, cb, options) {
208
- if (isFunction(defaultFileName)) {
209
- if (!isUndefined(cb)) {
210
- options = cb;
211
- }
212
- cb = defaultFileName;
213
- defaultFileName = null;
214
- }
215
-
216
- defaultFileName = defaultFileName || 'file.pdf';
217
- this.getBlob(function (result) {
218
- saveAs(result, defaultFileName);
219
-
220
- if (isFunction(cb)) {
221
- cb();
222
- }
223
- }, options);
224
- };
225
-
226
- Document.prototype.getBase64 = function (cb, options) {
227
- if (!cb) {
228
- throw 'getBase64 is an async method and needs a callback argument';
229
- }
230
- this.getBuffer(function (buffer) {
231
- cb(buffer.toString('base64'));
232
- }, options);
233
- };
234
-
235
- Document.prototype.getDataUrl = function (cb, options) {
236
- if (!cb) {
237
- throw 'getDataUrl is an async method and needs a callback argument';
238
- }
239
- this.getBuffer(function (buffer) {
240
- cb('data:application/pdf;base64,' + buffer.toString('base64'));
241
- }, options);
242
- };
243
-
244
- Document.prototype.getBlob = function (cb, options) {
245
- if (!cb) {
246
- throw 'getBlob is an async method and needs a callback argument';
247
- }
248
- var that = this;
249
- this.getBuffer(function (result) {
250
- var blob = that._bufferToBlob(result);
251
- cb(blob);
252
- }, options);
253
- };
254
-
255
- Document.prototype.getBuffer = function (cb, options) {
256
- if (!cb) {
257
- throw 'getBuffer is an async method and needs a callback argument';
258
- }
259
-
260
- var _this = this;
261
-
262
- this._createDoc(options, function (doc) {
263
- _this._flushDoc(doc, function (buffer) {
264
- cb(buffer);
265
- });
266
- });
267
- };
268
-
269
- Document.prototype.getStream = function (options, cb) {
270
- if (!isFunction(cb)) {
271
- var doc = this._createDoc(options);
272
- return doc;
273
- }
274
-
275
- this._createDoc(options, function (doc) {
276
- cb(doc);
277
- });
278
- };
11
+ if (!isBrowserSupported()) {
12
+ throw new Error('pdfmake: Internet Explorer 10 and older is not supported. Upgrade to version 11 or use modern browser.');
13
+ }
279
14
 
280
- module.exports = {
281
- createPdf: function (docDefinition, tableLayouts, fonts, vfs) {
282
- if (!canCreatePdf()) {
283
- throw 'Your browser does not provide the level of support needed';
284
- }
285
- return new Document(
286
- docDefinition,
287
- tableLayouts || global.pdfMake.tableLayouts,
288
- fonts || global.pdfMake.fonts,
289
- vfs || global.pdfMake.vfs
290
- );
291
- }
292
- };
15
+ module.exports = require('./index').default;
@@ -0,0 +1,27 @@
1
+ var fs = require('fs');
2
+
3
+ var fontContainer = {
4
+ vfs: {
5
+ 'data/Courier.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Courier.afm', 'utf8'), encoding: 'utf8' },
6
+ 'data/Courier-Bold.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Courier-Bold.afm', 'utf8'), encoding: 'utf8' },
7
+ 'data/Courier-Oblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Courier-Oblique.afm', 'utf8'), encoding: 'utf8' },
8
+ 'data/Courier-BoldOblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Courier-BoldOblique.afm', 'utf8'), encoding: 'utf8' }
9
+ },
10
+ fonts: {
11
+ Courier: {
12
+ normal: 'Courier',
13
+ bold: 'Courier-Bold',
14
+ italics: 'Courier-Oblique',
15
+ bolditalics: 'Courier-BoldOblique'
16
+ }
17
+ }
18
+ };
19
+
20
+ var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this;
21
+ if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
22
+ _global.pdfMake.addFontContainer(fontContainer);
23
+ }
24
+
25
+ if (typeof module !== 'undefined') {
26
+ module.exports = fontContainer;
27
+ }
@@ -0,0 +1,27 @@
1
+ var fs = require('fs');
2
+
3
+ var fontContainer = {
4
+ vfs: {
5
+ 'data/Helvetica.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica.afm', 'utf8'), encoding: 'utf8' },
6
+ 'data/Helvetica-Bold.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica-Bold.afm', 'utf8'), encoding: 'utf8' },
7
+ 'data/Helvetica-Oblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica-Oblique.afm', 'utf8'), encoding: 'utf8' },
8
+ 'data/Helvetica-BoldOblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Helvetica-BoldOblique.afm', 'utf8'), encoding: 'utf8' }
9
+ },
10
+ fonts: {
11
+ Helvetica: {
12
+ normal: 'Helvetica',
13
+ bold: 'Helvetica-Bold',
14
+ italics: 'Helvetica-Oblique',
15
+ bolditalics: 'Helvetica-BoldOblique'
16
+ }
17
+ }
18
+ };
19
+
20
+ var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this;
21
+ if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
22
+ _global.pdfMake.addFontContainer(fontContainer);
23
+ }
24
+
25
+ if (typeof module !== 'undefined') {
26
+ module.exports = fontContainer;
27
+ }
@@ -0,0 +1,21 @@
1
+ var fs = require('fs');
2
+
3
+ var fontContainer = {
4
+ vfs: {
5
+ 'data/Symbol.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Symbol.afm', 'utf8'), encoding: 'utf8' }
6
+ },
7
+ fonts: {
8
+ Symbol: {
9
+ normal: 'Symbol'
10
+ }
11
+ }
12
+ };
13
+
14
+ var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this;
15
+ if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
16
+ _global.pdfMake.addFontContainer(fontContainer);
17
+ }
18
+
19
+ if (typeof module !== 'undefined') {
20
+ module.exports = fontContainer;
21
+ }
@@ -0,0 +1,27 @@
1
+ var fs = require('fs');
2
+
3
+ var fontContainer = {
4
+ vfs: {
5
+ 'data/Times-Roman.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-Roman.afm', 'utf8'), encoding: 'utf8' },
6
+ 'data/Times-Bold.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-Bold.afm', 'utf8'), encoding: 'utf8' },
7
+ 'data/Times-Italic.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-Italic.afm', 'utf8'), encoding: 'utf8' },
8
+ 'data/Times-BoldItalic.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/Times-BoldItalic.afm', 'utf8'), encoding: 'utf8' }
9
+ },
10
+ fonts: {
11
+ Times: {
12
+ normal: 'Times-Roman',
13
+ bold: 'Times-Bold',
14
+ italics: 'Times-Italic',
15
+ bolditalics: 'Times-BoldItalic'
16
+ }
17
+ }
18
+ };
19
+
20
+ var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this;
21
+ if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
22
+ _global.pdfMake.addFontContainer(fontContainer);
23
+ }
24
+
25
+ if (typeof module !== 'undefined') {
26
+ module.exports = fontContainer;
27
+ }
@@ -0,0 +1,21 @@
1
+ var fs = require('fs');
2
+
3
+ var fontContainer = {
4
+ vfs: {
5
+ 'data/ZapfDingbats.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/@foliojs-fork/pdfkit/js/data/ZapfDingbats.afm', 'utf8'), encoding: 'utf8' }
6
+ },
7
+ fonts: {
8
+ ZapfDingbats: {
9
+ normal: 'ZapfDingbats'
10
+ }
11
+ }
12
+ };
13
+
14
+ var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : this;
15
+ if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
16
+ _global.pdfMake.addFontContainer(fontContainer);
17
+ }
18
+
19
+ if (typeof module !== 'undefined') {
20
+ module.exports = fontContainer;
21
+ }
@@ -0,0 +1 @@
1
+ module.exports = require('../virtual-fs').default;