pdfmake 0.3.2 → 0.3.4
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 +18 -0
- package/LICENSE +21 -21
- package/README.md +75 -78
- package/build/fonts/Roboto/Roboto-Italic.ttf +0 -0
- package/build/fonts/Roboto/Roboto-Medium.ttf +0 -0
- package/build/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
- package/build/fonts/Roboto/Roboto-Regular.ttf +0 -0
- package/build/fonts/Roboto.js +27 -0
- package/build/pdfmake.js +64813 -64584
- 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 -27
- package/build/standard-fonts/Helvetica.js +27 -27
- package/build/standard-fonts/Symbol.js +21 -21
- package/build/standard-fonts/Times.js +27 -27
- package/build/standard-fonts/ZapfDingbats.js +21 -21
- package/build/vfs_fonts.js +5 -5
- package/build-vfs.js +44 -44
- package/fonts/Roboto.js +8 -8
- package/js/3rd-party/svg-to-pdfkit/source.js +1 -1
- package/js/DocMeasure.js +11 -6
- package/js/DocumentContext.js +8 -3
- package/js/ElementWriter.js +42 -16
- package/js/LayoutBuilder.js +144 -78
- package/js/Line.js +16 -16
- package/js/OutputDocument.js +10 -10
- package/js/OutputDocumentServer.js +3 -3
- package/js/PDFDocument.js +3 -3
- package/js/PageElementWriter.js +15 -9
- package/js/Printer.js +28 -28
- package/js/Renderer.js +40 -8
- package/js/SVGMeasure.js +10 -10
- package/js/StyleContextStack.js +74 -51
- package/js/TableProcessor.js +14 -0
- package/js/TextBreaker.js +17 -17
- package/js/TextDecorator.js +12 -3
- package/js/TextInlines.js +34 -33
- package/js/base.js +4 -4
- package/js/browser-extensions/OutputDocumentBrowser.js +24 -24
- package/js/columnCalculator.js +2 -2
- package/js/helpers/node.js +47 -23
- package/js/helpers/variableType.js +18 -18
- package/js/qrEnc.js +38 -38
- package/js/virtual-fs.js +11 -11
- package/package.json +12 -12
- package/src/3rd-party/svg-to-pdfkit/LICENSE +9 -9
- package/src/3rd-party/svg-to-pdfkit/source.js +2745 -2745
- package/src/3rd-party/svg-to-pdfkit.js +3 -3
- package/src/DocMeasure.js +745 -738
- package/src/DocPreprocessor.js +283 -283
- package/src/DocumentContext.js +345 -338
- package/src/ElementWriter.js +441 -417
- package/src/LayoutBuilder.js +1336 -1258
- package/src/Line.js +114 -114
- package/src/OutputDocument.js +64 -64
- package/src/OutputDocumentServer.js +32 -32
- package/src/PDFDocument.js +174 -174
- package/src/PageElementWriter.js +187 -179
- package/src/PageSize.js +53 -53
- package/src/Printer.js +306 -306
- package/src/Renderer.js +445 -409
- package/src/SVGMeasure.js +109 -109
- package/src/StyleContextStack.js +208 -179
- package/src/TableProcessor.js +620 -602
- package/src/TextBreaker.js +168 -168
- package/src/TextDecorator.js +175 -161
- package/src/TextInlines.js +224 -223
- package/src/URLResolver.js +43 -43
- package/src/base.js +70 -70
- package/src/browser-extensions/OutputDocumentBrowser.js +80 -80
- package/src/browser-extensions/fonts/Roboto.js +27 -27
- package/src/browser-extensions/index.js +55 -55
- package/src/browser-extensions/pdfMake.js +1 -1
- package/src/browser-extensions/standard-fonts/Courier.js +27 -27
- package/src/browser-extensions/standard-fonts/Helvetica.js +27 -27
- package/src/browser-extensions/standard-fonts/Symbol.js +21 -21
- package/src/browser-extensions/standard-fonts/Times.js +27 -27
- package/src/browser-extensions/standard-fonts/ZapfDingbats.js +21 -21
- package/src/browser-extensions/virtual-fs-cjs.js +1 -1
- package/src/columnCalculator.js +154 -154
- package/src/helpers/node.js +134 -110
- package/src/helpers/tools.js +44 -44
- package/src/helpers/variableType.js +50 -50
- package/src/index.js +16 -16
- package/src/qrEnc.js +796 -796
- package/src/standardPageSizes.js +52 -52
- package/src/tableLayouts.js +100 -100
- package/src/virtual-fs.js +66 -66
- package/standard-fonts/Courier.js +8 -8
- package/standard-fonts/Helvetica.js +8 -8
- package/standard-fonts/Symbol.js +5 -5
- package/standard-fonts/Times.js +8 -8
- package/standard-fonts/ZapfDingbats.js +5 -5
package/src/base.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import Printer from './Printer';
|
|
2
|
-
import virtualfs from './virtual-fs';
|
|
3
|
-
import { pack } from './helpers/tools';
|
|
4
|
-
import { isObject } from './helpers/variableType';
|
|
5
|
-
|
|
6
|
-
class pdfmake {
|
|
7
|
-
|
|
8
|
-
constructor() {
|
|
9
|
-
this.virtualfs = virtualfs;
|
|
10
|
-
this.urlResolver = null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {object} docDefinition
|
|
15
|
-
* @param {?object} options
|
|
16
|
-
* @returns {object}
|
|
17
|
-
*/
|
|
18
|
-
createPdf(docDefinition, options = {}) {
|
|
19
|
-
if (!isObject(docDefinition)) {
|
|
20
|
-
throw new Error("Parameter 'docDefinition' has an invalid type. Object expected.");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (!isObject(options)) {
|
|
24
|
-
throw new Error("Parameter 'options' has an invalid type. Object expected.");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
options.progressCallback = this.progressCallback;
|
|
28
|
-
options.tableLayouts = this.tableLayouts;
|
|
29
|
-
|
|
30
|
-
let printer = new Printer(this.fonts, this.virtualfs, this.urlResolver());
|
|
31
|
-
const pdfDocumentPromise = printer.createPdfKitDocument(docDefinition, options);
|
|
32
|
-
|
|
33
|
-
return this._transformToDocument(pdfDocumentPromise);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
setProgressCallback(callback) {
|
|
37
|
-
this.progressCallback = callback;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
addTableLayouts(tableLayouts) {
|
|
41
|
-
this.tableLayouts = pack(this.tableLayouts, tableLayouts);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
setTableLayouts(tableLayouts) {
|
|
45
|
-
this.tableLayouts = tableLayouts;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
clearTableLayouts() {
|
|
49
|
-
this.tableLayouts = {};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
addFonts(fonts) {
|
|
53
|
-
this.fonts = pack(this.fonts, fonts);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
setFonts(fonts) {
|
|
57
|
-
this.fonts = fonts;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
clearFonts() {
|
|
61
|
-
this.fonts = {};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
_transformToDocument(doc) {
|
|
65
|
-
return doc;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default pdfmake;
|
|
1
|
+
import Printer from './Printer';
|
|
2
|
+
import virtualfs from './virtual-fs';
|
|
3
|
+
import { pack } from './helpers/tools';
|
|
4
|
+
import { isObject } from './helpers/variableType';
|
|
5
|
+
|
|
6
|
+
class pdfmake {
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
this.virtualfs = virtualfs;
|
|
10
|
+
this.urlResolver = null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {object} docDefinition
|
|
15
|
+
* @param {?object} options
|
|
16
|
+
* @returns {object}
|
|
17
|
+
*/
|
|
18
|
+
createPdf(docDefinition, options = {}) {
|
|
19
|
+
if (!isObject(docDefinition)) {
|
|
20
|
+
throw new Error("Parameter 'docDefinition' has an invalid type. Object expected.");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!isObject(options)) {
|
|
24
|
+
throw new Error("Parameter 'options' has an invalid type. Object expected.");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
options.progressCallback = this.progressCallback;
|
|
28
|
+
options.tableLayouts = this.tableLayouts;
|
|
29
|
+
|
|
30
|
+
let printer = new Printer(this.fonts, this.virtualfs, this.urlResolver());
|
|
31
|
+
const pdfDocumentPromise = printer.createPdfKitDocument(docDefinition, options);
|
|
32
|
+
|
|
33
|
+
return this._transformToDocument(pdfDocumentPromise);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setProgressCallback(callback) {
|
|
37
|
+
this.progressCallback = callback;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
addTableLayouts(tableLayouts) {
|
|
41
|
+
this.tableLayouts = pack(this.tableLayouts, tableLayouts);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
setTableLayouts(tableLayouts) {
|
|
45
|
+
this.tableLayouts = tableLayouts;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
clearTableLayouts() {
|
|
49
|
+
this.tableLayouts = {};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
addFonts(fonts) {
|
|
53
|
+
this.fonts = pack(this.fonts, fonts);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
setFonts(fonts) {
|
|
57
|
+
this.fonts = fonts;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
clearFonts() {
|
|
61
|
+
this.fonts = {};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_transformToDocument(doc) {
|
|
65
|
+
return doc;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default pdfmake;
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import OutputDocument from '../OutputDocument';
|
|
2
|
-
import { saveAs } from 'file-saver';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @returns {Window}
|
|
6
|
-
*/
|
|
7
|
-
const openWindow = () => {
|
|
8
|
-
// we have to open the window immediately and store the reference
|
|
9
|
-
// otherwise popup blockers will stop us
|
|
10
|
-
let win = window.open('', '_blank');
|
|
11
|
-
if (win === null) {
|
|
12
|
-
throw new Error('Open PDF in new window blocked by browser');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return win;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
class OutputDocumentBrowser extends OutputDocument {
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @returns {Promise<Blob>}
|
|
22
|
-
*/
|
|
23
|
-
async getBlob() {
|
|
24
|
-
const buffer = await this.getBuffer();
|
|
25
|
-
return new Blob([buffer], { type: 'application/pdf' });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param {string} filename
|
|
30
|
-
* @returns {Promise}
|
|
31
|
-
*/
|
|
32
|
-
async download(filename = 'file.pdf') {
|
|
33
|
-
const blob = await this.getBlob();
|
|
34
|
-
saveAs(blob, filename);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @param {Window} win
|
|
39
|
-
* @returns {Promise}
|
|
40
|
-
*/
|
|
41
|
-
async open(win = null) {
|
|
42
|
-
if (!win) {
|
|
43
|
-
win = openWindow();
|
|
44
|
-
}
|
|
45
|
-
const blob = await this.getBlob();
|
|
46
|
-
try {
|
|
47
|
-
let urlCreator = window.URL || window.webkitURL;
|
|
48
|
-
let pdfUrl = urlCreator.createObjectURL(blob);
|
|
49
|
-
win.location.href = pdfUrl;
|
|
50
|
-
|
|
51
|
-
/* temporarily disabled
|
|
52
|
-
if (win === window) {
|
|
53
|
-
return;
|
|
54
|
-
} else {
|
|
55
|
-
setTimeout(() => {
|
|
56
|
-
if (win.window === null) { // is closed by AdBlock
|
|
57
|
-
window.location.href = pdfUrl; // open in actual window
|
|
58
|
-
}
|
|
59
|
-
return;
|
|
60
|
-
}, 500);
|
|
61
|
-
}
|
|
62
|
-
*/
|
|
63
|
-
} catch (e) {
|
|
64
|
-
win.close();
|
|
65
|
-
throw e;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @param {Window} win
|
|
71
|
-
* @returns {Promise}
|
|
72
|
-
*/
|
|
73
|
-
async print(win = null) {
|
|
74
|
-
const stream = await this.getStream();
|
|
75
|
-
stream.setOpenActionAsPrint();
|
|
76
|
-
await this.open(win);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export default OutputDocumentBrowser;
|
|
1
|
+
import OutputDocument from '../OutputDocument';
|
|
2
|
+
import { saveAs } from 'file-saver';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @returns {Window}
|
|
6
|
+
*/
|
|
7
|
+
const openWindow = () => {
|
|
8
|
+
// we have to open the window immediately and store the reference
|
|
9
|
+
// otherwise popup blockers will stop us
|
|
10
|
+
let win = window.open('', '_blank');
|
|
11
|
+
if (win === null) {
|
|
12
|
+
throw new Error('Open PDF in new window blocked by browser');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return win;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
class OutputDocumentBrowser extends OutputDocument {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @returns {Promise<Blob>}
|
|
22
|
+
*/
|
|
23
|
+
async getBlob() {
|
|
24
|
+
const buffer = await this.getBuffer();
|
|
25
|
+
return new Blob([buffer], { type: 'application/pdf' });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} filename
|
|
30
|
+
* @returns {Promise}
|
|
31
|
+
*/
|
|
32
|
+
async download(filename = 'file.pdf') {
|
|
33
|
+
const blob = await this.getBlob();
|
|
34
|
+
saveAs(blob, filename);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param {Window} win
|
|
39
|
+
* @returns {Promise}
|
|
40
|
+
*/
|
|
41
|
+
async open(win = null) {
|
|
42
|
+
if (!win) {
|
|
43
|
+
win = openWindow();
|
|
44
|
+
}
|
|
45
|
+
const blob = await this.getBlob();
|
|
46
|
+
try {
|
|
47
|
+
let urlCreator = window.URL || window.webkitURL;
|
|
48
|
+
let pdfUrl = urlCreator.createObjectURL(blob);
|
|
49
|
+
win.location.href = pdfUrl;
|
|
50
|
+
|
|
51
|
+
/* temporarily disabled
|
|
52
|
+
if (win === window) {
|
|
53
|
+
return;
|
|
54
|
+
} else {
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
if (win.window === null) { // is closed by AdBlock
|
|
57
|
+
window.location.href = pdfUrl; // open in actual window
|
|
58
|
+
}
|
|
59
|
+
return;
|
|
60
|
+
}, 500);
|
|
61
|
+
}
|
|
62
|
+
*/
|
|
63
|
+
} catch (e) {
|
|
64
|
+
win.close();
|
|
65
|
+
throw e;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {Window} win
|
|
71
|
+
* @returns {Promise}
|
|
72
|
+
*/
|
|
73
|
+
async print(win = null) {
|
|
74
|
+
const stream = await this.getStream();
|
|
75
|
+
stream.setOpenActionAsPrint();
|
|
76
|
+
await this.open(win);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default OutputDocumentBrowser;
|
|
@@ -1,27 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import pdfmakeBase from '../base';
|
|
2
|
-
import OutputDocumentBrowser from './OutputDocumentBrowser';
|
|
3
|
-
import URLResolver from '../URLResolver';
|
|
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 URLResolver(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
|
+
import pdfmakeBase from '../base';
|
|
2
|
+
import OutputDocumentBrowser from './OutputDocumentBrowser';
|
|
3
|
+
import URLResolver from '../URLResolver';
|
|
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 URLResolver(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 +1 @@
|
|
|
1
|
-
module.exports = require('./index').default;
|
|
1
|
+
module.exports = require('./index').default;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
var fs = require('fs');
|
|
2
|
-
|
|
3
|
-
var fontContainer = {
|
|
4
|
-
vfs: {
|
|
5
|
-
'data/Courier.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Courier.afm', 'utf8'), encoding: 'utf8' },
|
|
6
|
-
'data/Courier-Bold.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Courier-Bold.afm', 'utf8'), encoding: 'utf8' },
|
|
7
|
-
'data/Courier-Oblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Courier-Oblique.afm', 'utf8'), encoding: 'utf8' },
|
|
8
|
-
'data/Courier-BoldOblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/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
|
-
}
|
|
1
|
+
var fs = require('fs');
|
|
2
|
+
|
|
3
|
+
var fontContainer = {
|
|
4
|
+
vfs: {
|
|
5
|
+
'data/Courier.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Courier.afm', 'utf8'), encoding: 'utf8' },
|
|
6
|
+
'data/Courier-Bold.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Courier-Bold.afm', 'utf8'), encoding: 'utf8' },
|
|
7
|
+
'data/Courier-Oblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Courier-Oblique.afm', 'utf8'), encoding: 'utf8' },
|
|
8
|
+
'data/Courier-BoldOblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/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
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
var fs = require('fs');
|
|
2
|
-
|
|
3
|
-
var fontContainer = {
|
|
4
|
-
vfs: {
|
|
5
|
-
'data/Helvetica.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Helvetica.afm', 'utf8'), encoding: 'utf8' },
|
|
6
|
-
'data/Helvetica-Bold.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Helvetica-Bold.afm', 'utf8'), encoding: 'utf8' },
|
|
7
|
-
'data/Helvetica-Oblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Helvetica-Oblique.afm', 'utf8'), encoding: 'utf8' },
|
|
8
|
-
'data/Helvetica-BoldOblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/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
|
-
}
|
|
1
|
+
var fs = require('fs');
|
|
2
|
+
|
|
3
|
+
var fontContainer = {
|
|
4
|
+
vfs: {
|
|
5
|
+
'data/Helvetica.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Helvetica.afm', 'utf8'), encoding: 'utf8' },
|
|
6
|
+
'data/Helvetica-Bold.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Helvetica-Bold.afm', 'utf8'), encoding: 'utf8' },
|
|
7
|
+
'data/Helvetica-Oblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/pdfkit/js/data/Helvetica-Oblique.afm', 'utf8'), encoding: 'utf8' },
|
|
8
|
+
'data/Helvetica-BoldOblique.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/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
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var fs = require('fs');
|
|
2
|
-
|
|
3
|
-
var fontContainer = {
|
|
4
|
-
vfs: {
|
|
5
|
-
'data/Symbol.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/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
|
-
}
|
|
1
|
+
var fs = require('fs');
|
|
2
|
+
|
|
3
|
+
var fontContainer = {
|
|
4
|
+
vfs: {
|
|
5
|
+
'data/Symbol.afm': { data: fs.readFileSync(__dirname + '/../../../node_modules/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
|
+
}
|