Open deepuab opened 5 years ago
I'm having the same issue. It works when you do the "node yourscript.js" on terminal but when I compiled it using the pkg and run the .exe file it shows this error:
{ Error: Command failed: java -jar "C:\snapshot\DakabiApp\node_modules\easy-pdf-merge\jar\pdfbox.jar" PDFMerger "_temp/temp01558608247085.pdf" "_temp/temp11558608247106.pdf" "_temp/combined.pdf" Error: Unable to access jarfile C:\snapshot\DakabiApp\node_modules\easy-pdf-merge\jar\pdfbox.jar at ChildProcess.exithandler (child_process.js:281:12) at emitTwo (events.js:126:13) at ChildProcess.emit (events.js:214:7) at maybeClose (internal/child_process.js:915:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) killed: false, code: 1, signal: null, cmd: 'java -jar "C:\snapshot\DakabiApp\node_modules\easy-pdf-merge\jar\pdfbox.jar" PDFMerger "_temp/temp01558608247085.pdf" "_temp/temp11558608247106.pdf" "_temp/combined.pdf"' }
Even though the pdfbox.jar exists inside the node_modules, it appears that the said file is missing after compiling using pkg.
@GoodLadCarlos could you please explain what you mean when you say you compiled it using the pkg and ran the exe?
@GoodLadCarlos And I think the issue posted by @deepuab is different as I see a different error. May be you could raise a different issue and continue the conversation there :)
@karuppiah7890 If I am not mistaken, I believe that @deepuab and I are using the same compiler "package or pkg" to convert the script into a desktop application. For example:
I have a javascript file named as "myscript.js" which includes the easy-pdf-merge workarounds.
It works fine when you do the "node myscript.js" on the terminal.
Then I compiled it using the pkg so the javascript file "myscript.js" will gonna be look like this "myscript.exe"
And I run the "myscript.exe" then it throws the error that says "Error: Command failed: java -jar" which I think that I can't access the "node_modules/easy-pdf-merge/jar/pdfbox.jar" when file is already executable.
I still have an option to create my app and having the easy-pdf-merge on electron instead of pkg and see if Im still having the same issue. check this pkg reference
Thank you
@karuppiah7890 I replicate my app and compile it using electron-packager and run it. Im still having the same issue:
{ Error: Command failed: java -jar "C:\Users\Cyle Jose Aguinaldo\Desktop\electron-app\release-builds\app-clerk-win32-ia32\resources\app.asar\node_modules\easy-pdf-merge\jar\pdfbox.jar" PDFMerger "_temp/temp01558789281246.pdf" "_temp/temp11558789281302.pdf" "_temp/temp21558789281304.pdf" "_temp/temp31558789281305.pdf" "_temp/temp41558789281305.pdf" "_temp/temp51558789281306.pdf" "_temp/temp61558789281306.pdf" "_temp/combined.pdf" Error: Unable to access jarfile C:\Users\Cyle Jose Aguinaldo\Desktop\electron-app\release-builds\app-clerk-win32-ia32\resources\app.asar\node_modules\easy-pdf-merge\jar\pdfbox.jar at ChildProcess.exithandler (child_process.js:308:12) at ChildProcess.emit (events.js:194:13) at maybeClose (internal/child_process.js:998:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5) killed: false, code: 1, signal: null, cmd: 'java -jar "C:\Users\Cyle Jose Aguinaldo\Desktop\electron-app\release-builds\app-clerk-win32-ia32\resources\app.asar\node_modules\easy-pdf-merge\jar\pdfbox.jar" PDFMerger "_temp/temp01558789281246.pdf" "_temp/temp11558789281302.pdf" "_temp/temp21558789281304.pdf" "_temp/temp31558789281305.pdf" "_temp/temp41558789281305.pdf" "_temp/temp51558789281306.pdf" "_temp/temp61558789281306.pdf" "_temp/combined.pdf"' }
This time the script cant access the pdfbox.jar inside the app.asar. I'm still finding another way for a solution. I will let you know if there's a progress. Thanks
@GoodLadCarlos Thanks for the context. I will have to reproduce the issue and see what's causing it, may be check what pkg, or electron does to do the packaging. I did create a demo electron app with this - https://github.com/karuppiah7890/pdf-merger-app .
It's been long since I worked in these projects. I will try to put some effort and try to help with this.
Other than this, I have also had thoughts of how using a npm module behind the scenes, instead of PDFBox (which requires a jar and java to be installed) will help. A colleague suggested the idea, talking about https://github.com/foliojs/pdfkit and another library. But having a glance at them looks like they don't provide the feature of merging PDFs, may be I need to spend more time on it. But on digging further, I found some good libs, one of them is https://www.npmjs.com/package/pdf-lib and some more are mentioned in the same page - https://www.npmjs.com/package/pdf-lib#prior-art .
But we will have to come up with Pros and Cons of such a solution (not using an external thing like PDFBox behind the scenes) and try to keep it completely JS and also see the feasibility of it. And I think PDFBox is surely great, and probably mature, coming from Apache and I think it's been in development for years, so replacing it means the npm module should provide good enough features with no issues. Probably a big call. May be we can raise a RFC issue and discuss it. cc @g0ddish (the current maintainer)
@GoodLadCarlos @deepuab ...I am facing same issue.I was able to merge files when i was running app from terminal, but after I packaged it I get same error when merging files. Could you please help me ?
@uzair4100 One of the pdfs which i tried to merge was corrupted. It was issue with my pdf generation logic. The merge issue got resolved when i removed the error pdf from merge.
but i am still getting this error
Error: Command failed: java -jar "C:\Users\uzaira\AppData\Local\Programs\pdf-application\resources\app.asar\node_modules\easy-pdf-merge\jar\pdfbox.jar" PDFMerger "C:\Users\uzaira\Desktop\Student_Files\coverLetter\CHI_SL_Y9_1_CB_1.pdf.(06 student name) .pdf" "C:\Users\uzaira\Desktop\Student_Files\coursebooks\CHI_SL_Y9_1_CB_1.pdf" "C:\Users\uzaira\Desktop\Student_Files\readytoprint/(06 student name) .pdf" Error: Unable to access jarfile C:\Users\uzaira\AppData\Local\Programs\pdf-application\resources\app.asar\node_modules\easy-pdf-merge\jar\pdfbox.jar
at ChildProcess.exithandler (child_process.js:308)
at ChildProcess.emit (events.js:210)
at maybeClose (internal/child_process.js:1021)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283)
It works fine when I run app with "npm start" from terminal.It gives me error when I package app using electron builder and try to merge pdf's.
I m getting below error while trying to merge pdfs using the package