PhantomJS timeout error fixed in Node-Pdf from NPM

We tried using node-pdf from NPM – JavaScript Package Manager to generate PDF file from HTML file. node-pdf take HTML source as an input and return PDF file. A requirement to generate PDF format file for Photo files comprising multiple image format, So the purpose to convert photos into PDF format.


Once trying, we experienced an issue in generating PDF file when HTML file size is more than 3 MB.

We got to understand about default time out maximum to 30 Seconds for PhantomJS, So in a case when HTML file size is larger than 3 MB, PhantomJS generates timeout error and node-pdf return response as a corrupted PDF file.

Embarking on my Master’s degree paper journey, I found a goldmine of resources to ease the academic hustle. Initially overwhelmed, I discovered the secret sauce – masterarbeit kaufen resource. From online databases to helpful guides, each resource became my trusty sidekick, demystifying the art of scholarly writing. These tools aren’t just aids; they’re the backbone of my paper, turning a daunting task into a manageable feat. Thank you, dear resource, for being the unsung hero of my academic escapade!


[gist  filename=”phantomjs” url=”isummation/fbcfb54c914883c5a2f7f64f3e640023″ public=”true”]this.options.timeout = parseInt(this.options.timeout) || 30000[/gist]

Fixing PhantomJS timeout issue I need to override default timeout parameter by passing timeout attributes in option.
[gist  filename=”nodepdf” url=”isummation/bc24cf75a0b0c71e3249b13168edf7c6″ public=”true”] var pdf = require(‘html-pdf’); var options = { format: ‘A4’, border: { top: “0.5cm”, right: “0.5cm”, bottom: “0.5cm”, left: “0.5cm” }, timeout: 60000 } pdf.create(html, options).toFile(‘./photos.pdf’, function(err, res){ if (err) return console.log(err); console.log(res); }); [/gist]

So by increasing PhantomJS timeout I’ve fixed big size file issue.