node-html-pdf icon indicating copy to clipboard operation
node-html-pdf copied to clipboard

html-pdf: Unknown Error

Open ananth03 opened this issue 6 years ago • 15 comments

html-pdf throw unknown error for bulk pdf convertion (above 200 html string).

ananth03 avatar Jan 25 '18 10:01 ananth03

same problem! any solution?

alisherafat01 avatar Apr 18 '18 15:04 alisherafat01

same here :(

Liquid-NeoN avatar Jun 26 '18 07:06 Liquid-NeoN

same here. Any solution? Error: html-pdf: Unknown Error at ChildProcess.respond (/app/server/sds-platform/node_modules/html-pdf/lib/pdf.js:122:28) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at Process.ChildProcess._handle.onexit (internal/child_process.js:219:12)

kukrejaravi9 avatar Jul 10 '18 12:07 kukrejaravi9

I'm having the same issue, any solution ?

jubarbie avatar Jan 02 '19 17:01 jubarbie

I got same error when i tried to generate 3 PDF at same time, but i got solution. Just need to generate PDF one by one. I put code in async.waterfall with 3 functions. so PDF will generate one by one.

bhedashakil avatar Jan 15 '19 08:01 bhedashakil

We had the same issue and the fix mentionned by bhedashakil worked for us.

Running tasks un series instead of parallel was it. We used Bluebird for promises, so it was an easy fix

Promise.map(convertJobs, job => {

into

Promise.mapSeries(convertJobs, job => {

savoiebz avatar Feb 06 '19 18:02 savoiebz

@bhedashakil @savoiebz could you explain what you did to fix the issue? I can't seem to get it to function correctly

diegoolavarria avatar Apr 23 '19 15:04 diegoolavarria

Personnaly, the issue I had got resolved when we stopped generating PDFs in parallel, instead we ran them in series. I think the lib was trying to spawn too many PhantomJS and was causing issues. If you aren't used to theses concepts: I suggest you read a bit on it. It is at the very core of NodeJS developpement. But basically, it is doing functions at the time vs one after the other one. If you know already all this, sorry to bother.

There is a handfull of library that allow you to handle asynchronous NodeJS events. If you program using Promises, I highly suggest using Bluebird. If you are still working with callbacks, you can use something like async(And maybe look into upgrading to promises someday 😊 ).

If it is not the kind of answer you were expecting, maybe you expand on your question or you could share a bit of code and I can try my best to have a look at it.

savoiebz avatar Apr 23 '19 15:04 savoiebz

It is best to investigate about: Parallel, Serial, Waterfall and Queues for "general culture".

If is a bulk process you can make this way:

import pdf from 'pdf-creator-node'
...
for (const arrays of array) {  // -> control the flow sequentially. 
    ...
    await pdf.create(document, options)
        .then(res => {
            console.log(res)
        })
        .catch(error => {
             console.error(error)
        })
    ...
}
...

This run the script of sequense way, will should not have problems.

alejosv avatar Feb 18 '21 18:02 alejosv

hi, i am resolve with changes in my html content, check this https://github.com/marcbachmann/node-html-pdf/blob/master/examples/businesscard/businesscard.html

thanks ...

ivancho2802 avatar Aug 14 '21 20:08 ivancho2802

This doesn't use node, but here is a great video nevertheless! It converts HTML to PDF directly in HTML. This integrates both HTML + CSS + images into a PDF: https://www.youtube.com/watch?v=zmJV6VN2h2E . Hopefully this helps with your error

Eesha-Jain avatar Dec 29 '21 00:12 Eesha-Jain

i got the same problem on production using heroku. The solution for me was creating a new env var OPENSSL_CONF with value /dev/null.

https://prnt.sc/VaOabzLAXFlO

i added to heroku env vars and it worked for me.

scush989898 avatar Sep 13 '22 04:09 scush989898

iam having same issue Please give me the solution...

Shijors avatar Dec 16 '22 16:12 Shijors

@scush989898 's solution worked for me on Heroku! Thanks!

8ctopotamus avatar Jan 05 '23 18:01 8ctopotamus

I found this answer and it worked for me in Stackoverfow

josegoyo avatar Dec 05 '23 20:12 josegoyo