docxtopdf2 1.1.2 → 1.1.3
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/package.json +1 -1
- package/src/runner.js +19 -17
package/package.json
CHANGED
package/src/runner.js
CHANGED
|
@@ -5,30 +5,32 @@ import { fileURLToPath } from "url";
|
|
|
5
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = path.dirname(__filename);
|
|
7
7
|
|
|
8
|
-
function getBinary() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// function getPdfConvertorPath() {
|
|
22
|
-
// return join(__dirname, "../", "bin", "pdf_convertor.exe");
|
|
8
|
+
// function getBinary() {
|
|
9
|
+
// switch (process.platform) {
|
|
10
|
+
// case "win32":
|
|
11
|
+
// return join(__dirname, "../bin/win32/processor.exe");
|
|
12
|
+
// case "linux":
|
|
13
|
+
// return join(__dirname, "../bin/linux/processor");
|
|
14
|
+
// case "darwin":
|
|
15
|
+
// return join(__dirname, "../bin/darwin/processor");
|
|
16
|
+
// default:
|
|
17
|
+
// throw new Error("Unsupported OS");
|
|
18
|
+
// }
|
|
23
19
|
// }
|
|
24
20
|
|
|
21
|
+
function getPdfConvertorPath() {
|
|
22
|
+
return join(__dirname, "../", "bin", "pdf_convertor.exe");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
25
|
function convertDocxToPdf(inputDocxPath) {
|
|
26
26
|
return new Promise((resolve, reject) => {
|
|
27
|
-
const bin = getBinary();
|
|
27
|
+
// const bin = getBinary();
|
|
28
28
|
|
|
29
29
|
const outputPdfPath = inputDocxPath.replace(".docx", ".pdf");
|
|
30
30
|
|
|
31
|
-
const python = spawn(
|
|
31
|
+
const python = spawn(getPdfConvertorPath(), [
|
|
32
|
+
(inputDocxPath, outputPdfPath),
|
|
33
|
+
]);
|
|
32
34
|
|
|
33
35
|
let result = "";
|
|
34
36
|
let error = "";
|