Rajni     Aug,23 2017

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.

 

Fixing PhantomJS timeout issue I need to override default timeout parameter by passing timeout attributes in option.
 

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