forked from bpampuch/pdfmake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.js
61 lines (46 loc) · 1.15 KB
/
base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import Printer from './Printer';
import virtualfs from './virtual-fs';
import { pack } from './helpers/tools';
class pdfmake {
constructor() {
this.virtualfs = virtualfs;
this.urlResolver = null;
}
/**
* @param {object} docDefinition
* @param {?object} options
* @returns {object}
*/
createPdf(docDefinition, options = {}) {
options.progressCallback = this.progressCallback;
options.tableLayouts = this.tableLayouts;
let printer = new Printer(this.fonts, this.virtualfs, this.urlResolver);
const pdfDocumentPromise = printer.createPdfKitDocument(docDefinition, options);
return this._transformToDocument(pdfDocumentPromise);
}
setProgressCallback(callback) {
this.progressCallback = callback;
}
addTableLayouts(tableLayouts) {
this.tableLayouts = pack(this.tableLayouts, tableLayouts);
}
setTableLayouts(tableLayouts) {
this.tableLayouts = tableLayouts;
}
clearTableLayouts() {
this.tableLayouts = {};
}
addFonts(fonts) {
this.fonts = pack(this.fonts, fonts);
}
setFonts(fonts) {
this.fonts = fonts;
}
clearFonts() {
this.fonts = {};
}
_transformToDocument(doc) {
return doc;
}
}
export default pdfmake;