Node-html-pdf: Cant open pdf_a4_portrait.js inside app.asar

Created on 29 Apr 2018  路  6Comments  路  Source: marcbachmann/node-html-pdf

Hello good day,

I am unable to create pdf files if I will enable the asar on the electron-builder.

When tried to execute it I am getting this error.

C:\Users\gust 7\AppData\Local\Programs\ex\resources\app.asar\app\methods.js:1388 Error: html-pdf: Received the exit code '4294967295'
Can't open 'C:\Users\gust 7\AppData\Local\Programs\ex\resources\app.asar\node_modules\html-pdf\lib\scripts\pdf_a4_portrait.js'

    at ChildProcess.respond (C:\Users\gust 7\AppData\Local\Programs\ex\resources\app.asar\node_modules\html-pdf\lib\pdf.js:121)
    at emitTwo (events.js:125)
    at ChildProcess.emit (events.js:213)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:200)

I will greatly appreciate, any advice will come.

thanks.

Most helpful comment

Hey @Karzeus

I was able to fix it by including the complete path to the file in the option object.

const pdf_options = { 
            format: 'Letter',
            header: {
                height: "20mm"
              },
            footer: {
                height: "15mm"
            },
            script: path.join(pathToFile, 'pdf_a4_portrait.js')
        }

All 6 comments

I suspect the space in your path (gust_7) might be causing a problem, as this is a common problem for files not being "found" when trying to open them.
Perhaps you could try wrapping your path string (C:Usersgust 7AppDataLocalProgramsexresourcesapp.asarnode_moduleshtml-pdflibscriptspdf_a4_portrait.js) in double quotes, or remove the space?

I tried to create new user without spaces on the name, but I still got the same error.

I am having the same Issue.

Trying to integrate it with pkg.
Any news?

Error: html-pdf: Received the exit code '4294967295'
Can't open 'C:\snapshot\user_log\node_modules\html-pdf\lib\scripts\pdf_a4_portrait.js'

    at ChildProcess.respond (C:\snapshot\user_log\node_modules\html-pdf\lib\pdf.js:121:31)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)

I have the exact same problem as you, @Jucesr using pkg. Did you find a way to solve this?

Hey @Karzeus

I was able to fix it by including the complete path to the file in the option object.

const pdf_options = { 
            format: 'Letter',
            header: {
                height: "20mm"
              },
            footer: {
                height: "15mm"
            },
            script: path.join(pathToFile, 'pdf_a4_portrait.js')
        }

Hi
First try to unpack the html-pdf module like "electron-packager . test--overwrite --asar.unpackDir=node_modules/html-pdf " and use the method provided by @Karzeus but change the script path to "path.join(__dirname,'node_modules/html-pdf/lib/scripts/pdf_a4_portrait.js').replace('app.asar\src', 'app.asar.unpacked');",that should work goodluck.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Messilimeng picture Messilimeng  路  4Comments

Mortuie picture Mortuie  路  4Comments

vivekiyer114 picture vivekiyer114  路  5Comments

OussamaRomdhane picture OussamaRomdhane  路  4Comments

adman020 picture adman020  路  5Comments