wubzz / pdf-merge

Merge multiple PDF Files into a single PDF document
127 stars 32 forks source link

'pdftk' is not recognized as an internal or external command #16

Closed pwong2 closed 7 years ago

pwong2 commented 7 years ago
Unhandled rejection Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "pdftk "31296.pdf" "31297.pdf" "31298.pdf" "31299.pdf" "31300.pdf" "31301.pdf" "31302.pdf" "31303.pdf" "31304.pdf" "31305.pdf" "31306.pdf" "31307.pdf" "31308.pdf" "31309.pdf" "31310.pdf" "31311.pdf" "31312.pdf" "31313.pdf" "31314.pdf" "31315.pdf" "31316.pdf" "31317.pdf" "31318.pdf" "31319.pdf" "31320.pdf" "31321.pdf" "31322.pdf" "31323.pdf" "31324.pdf" "31325.pdf" "31326.pdf" "31354.pdf" "31355.pdf" "31356.pdf" "31357.pdf" "31358.pdf" "31359.pdf" "31360.pdf" "31361.pdf" "31362.pdf" "batch" cat output C:\WINDOWS\TEMP\tmp-17588xpteWrpW66Au"
'pdftk' is not recognized as an internal or external command,

operable program or batch file.

    at ChildProcess.exithandler (child_process.js:213:12)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:829:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

@wubzz can you help me on this please? I already searched the other possible like installing the pdftk, but can't find any solution.

pwong2 commented 7 years ago

@wubzz UPDATE:

I tried to use this

PDFMerge(pdfFiles, { output: 'temp/batch/batch1.pdf', libPath: 'C:\Program Files (x86)\PDFtk\bin' })
                    .then(() => {
                        res.writeHead(200);
                        res.end();
                    });

then I encountered this,

Unhandled rejection Error: spawn C:Program Files (x86)PDFtkin ENOENT
    at exports._errnoException (util.js:907:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)
wubzz commented 7 years ago

@pwong2 Either add C:/Program Files (x86)/PDFtk/bin to your path, or change option libPath to C:\\Program Files (x86)\\PDFtk\\bin\\pdftk.exe.

Your second attempt was almost correct. But you have to escape the backslashes.