You are currently viewing How to solve PDFcrowd convertURL method’s 40 seconds timeout limit problem

How to solve PDFcrowd convertURL method’s 40 seconds timeout limit problem

  • Post published:March 4, 2014


Client asked the developer of vteam #358 to generate HTML based Client Summary Report for monthly/yearly data; convert that report to PDF, email the report to the creator/client and all these actions should be done in one single request. The report contained numerous charts and graphs along with complete details of all orders completed by each representative of the client. A client could have more than one representative, the maximum number of representatives of a client totaled at 120. Admin could view report in browser in HTML format or email as PDF format.

Technical Challenge:

PDFcrowd provided two methods to convert HTML into PDF:

  • convertURL (; which coverts HTML on a URL to PDF
  • convertHTML ($html); which converts HTML string into PDF

Tariq used first method of for generating PDF which was successful in case of normal amount of report data but started to fail for large amount of data. After the investigation, it was found that PDFcrowd imposes a time out limit of 40 seconds on data retrieval from a URL. This is a limitation of PDFcrowd and there is no way to increase the time out limit. Tariq tried the second method which was to create HTML and send to PDFcrowd for generating PDF report. He used CURL to get the HTML contents of report but was failed to get desired results because jqPlot was used to create charts. jqPlot is a client side library to create charts/graphs and CURL don’t wait for the JS to execute so charts were not generated at all.


Tariq recoded the page using jQuery to solve the problem and made sure that the report is rendered by browser, on document, ready event grabbed HTML of the report, sent an AJAX call to PDFcrowd for generation of PDF, on success of AJAX request emailed the PDF to user/client.

Unfortunately another problem was observed; the layout of charts was disturbed because jqPlot draws charts on HTML 5 canvas elements and when that canvas elements were sent as HTML string the chart labels went missing and legends were also disturbed. To resolve this, Tariq added code to convert the charts into images and replaced canvas elements with images then sent the HTML to PDFcrowd for PDF generation and finally it worked as per Client’s requirement.