title: TCPDF takes 10 minutes to generate a 40 page pdf file
body: <p>I have a report generation PHP program which used to work fine before. I have used 2 3rd party libraries in the program: Google image chart library ( returns image if I supply values in url ) and tcpdf ( for pdf generation ). I am using mysql not mysqli for queries. There are lots of queries and loops in the page.</p>
  
  <p>Before it used to take less than 3 minutes to generate the report, I am using an ajax call to generate the report which gives a completed message once the file generation is done. This program saves the pdf file in a folder and I have a link with same name to download the file.</p>
  
  <p>Recently when I checked its not generating properly.</p>
  
  <p>Error was TCPDF unable to get the image. This was because of the google chart library not returning the image properly. When I access the chart url in browser it gives me the image without any issue but If I give it in an image src inside a php file, its not showing. So I decided to save the file in a folder using functions like file_get_contents,file_put_contents and link it in image src. This part is now working correctly I can see the image.</p>
  
  <p>But now the problem is it is taking a lot of time to generate the report, even in  local environment. I tried to generate the report without the chart priniting but even then its taking time. In between it was 25 minutes n all and now its close to 10 minutes to generate a 40 page pdf file.</p>
  
  <p>I really don't know why its taking so much time. All of this was working fine before and now its not working. Only thing that changed was google image chart library but now even without(commented that part and checked) that also its taking time.</p>
  
  <p><strong>How do I speed this up ? Is there any way to check which part of program is slow.</strong></p>
  
  <p>Tried xdebug but its output file is more than 400 mb and webgrind is not able to process it.</p>
  
  <p>Please help.</p>