Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node html-pdf Auto configuration failed

I have a simple project using html-pdf package, I'd like to make a simple pdf file with this code :

...
    pdf.create(html).toStream(function(err, stream){
            if (err) reject(err) ;
            else  stream.pipe(fs.createWriteStream(path.join(__dirname, '../../../assets/docs/idv_docs/')+data.link+'.pdf'));
          });
...

but I get this error messsage :

Error: html-pdf: Received the exit code '1'

    cc-server_1  | Auto configuration failed
    cc-server_1  | 139666354437760:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libssl_conf.so): libssl_conf.so: cannot open shared object file: No such file or directory
    cc-server_1  | 139666354437760:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
    cc-server_1  | 139666354437760:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=ssl_conf, path=ssl_conf
    cc-server_1  | 139666354437760:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=ssl_conf
    cc-server_1  |
    cc-server_1  |     at ChildProcess.respond (/usr/src/app/node_modules/html-pdf/lib/pdf.js:121:31)
    cc-server_1  |     at ChildProcess.emit (events.js:311:20)
    cc-server_1  |     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
like image 277
Bilel-Zheni Avatar asked Dec 01 '25 14:12

Bilel-Zheni


2 Answers

Solution without devOps

  • fixed SSL issue: simulate empty config https://github.com/bazelbuild/rules_closure/issues/351#issuecomment-1116945290
  • html-pdf assept options for childprocess wich will be paseed into phantomJs
  • node_modules/html-pdf/lib/pdf.js:89 (childProcessOptions)
  • https://nodejs.org/api/child_process.html
  • added env object to childProcessOptions for overriding OPENSSL_CONF
pdf.create(html, {
  childProcessOptions: {
    env: {
      OPENSSL_CONF: '/dev/null',
    },
  }
}); 
like image 84
Toxic Dude Avatar answered Dec 03 '25 13:12

Toxic Dude


I had same problem, The problem is openssl.cnf file.
My operating system is Debian 10.
Try the following steps
Step 1: Go to /etc/ssl/openssl.cnf

Step 2: Find the following line and comment it.

# System default
openssl_conf = default_conf 

Step 3: Restart your node server

like image 39
Hossein Bajan Avatar answered Dec 03 '25 13:12

Hossein Bajan