polotno-node 0.2.1 → 0.2.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.
- package/index.js +19 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -75,22 +75,29 @@ module.exports.createInstance = async ({ key, url, useParallelPages } = {}) => {
|
|
|
75
75
|
return url.split('base64,')[1];
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
const jsonToPDFDataURL = async (json, attrs) => {
|
|
79
|
+
return await run(
|
|
80
|
+
async (json, attrs) => {
|
|
81
|
+
store.loadJSON(json);
|
|
82
|
+
await store.waitLoading();
|
|
83
|
+
return await store.toPDFDataURL(attrs);
|
|
84
|
+
},
|
|
85
|
+
json,
|
|
86
|
+
attrs || {}
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const jsonToPDFBase64 = async (json, attrs) => {
|
|
91
|
+
const url = await jsonToPDFDataURL(json, attrs);
|
|
92
|
+
return url.split('base64,')[1];
|
|
93
|
+
};
|
|
94
|
+
|
|
78
95
|
return {
|
|
79
96
|
close: async () => await browser.close(),
|
|
80
97
|
run,
|
|
81
98
|
jsonToDataURL,
|
|
82
99
|
jsonToImageBase64,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
async (json, attrs) => {
|
|
86
|
-
store.loadJSON(json);
|
|
87
|
-
await store.waitLoading();
|
|
88
|
-
const url = await store.toPDFDataURL(attrs);
|
|
89
|
-
return url.split('base64,')[1];
|
|
90
|
-
},
|
|
91
|
-
json,
|
|
92
|
-
attrs || {}
|
|
93
|
-
);
|
|
94
|
-
},
|
|
100
|
+
jsonToPDFDataURL,
|
|
101
|
+
jsonToPDFBase64,
|
|
95
102
|
};
|
|
96
103
|
};
|