Jump to content
  • 0

Change Max Execution Time Limit


Question

Posted

I've found TCPDF to be running quite slowly... it takes around 15 seconds or more to generate a PDF.  Are there any suggestions to speed up TCPDF or increase the PHP maximum execution time?  When I try to process multiple PDFs I am receiving the error "Maximum execution time of 30 seconds exceeded on line 5404 in ~/httpdocs/vendors/tcpdf/tcpdf.php"

 

In reading TCPDF's website, it makes the following recommendations to speed things up.  Any tips on how to implement any of these that would be useful to Blesta?

  • Install and configure a PHP opcode cacher like XCache;
  • Edit the php.ini file and increase the maximum amount of memory a script may consume (memory_limit);
  • Edit the php.ini file and increase the maximum execution time of each script (max_execution_time);
  • Edit the config/tcpdf_config.php file: manually set the $_SERVER['DOCUMENT_ROOT'], K_PATH_MAIN and K_PATH_URL constants, and remove the automatic calculation part;
  • If you are not using the Thai language, edit the config/tcpdf_config.php file and set the K_THAI_TOPCHARS constant to false;
  • If you do not need extended chars, edit the config/tcpdf_config.php file and set the default fonts to core fonts;
  • If you do not need UTF-8 Unicode, set the $unicode parameter on TCPDF constructor to false and the $encoding parameter to 'ISO-8859-1' or other character map.
  • By default TCPDF enables font subsetting to reduce the size of embedded Unicode TTF fonts, this process, that is very slow and requires a lot of memory, can be turned off using setFontSubsetting(false) method;
  • Use core fonts instead of embedded fonts whenever possible;
  • Avoid using the HTML syntax (writeHTML and writeHTMLCell methods) if not strictly required;
  • Split large HTML blocks in smaller pieces;
  • Avoid using transactions if not strictly required;

4 answers to this question

Recommended Posts

  • 0
Posted

Actually the suggestion to re-visit the logo and background images has led me to the solution.  The PNGs were originally output with alpha transparency.  Once I removed this and re-uploaded them to Blesta, the PDF appears almost instantly.

  • 0
Posted

Blesta doesn't use HTML syntax to render PDFs and I've never seen it take 15 seconds. It it instant for me.

 

Do you have a logo or background image uploaded for your PDFs? If so, remove them and see if it speeds it up any. If it does make a difference, you could try optimizing the images, and adding them back in to see if that makes a difference. Also, make sure you have the GD library if using images in the PDF -- TCPDF sometimes tries to call GD to manipulate images.

  • 0
Posted

Blesta doesn't use HTML syntax to render PDFs and I've never seen it take 15 seconds. It it instant for me.

 

Do you have a logo or background image uploaded for your PDFs? If so, remove them and see if it speeds it up any. If it does make a difference, you could try optimizing the images, and adding them back in to see if that makes a difference. Also, make sure you have the GD library if using images in the PDF -- TCPDF sometimes tries to call GD to manipulate images.

It's instant for me also. Sounds like some php.ini issues

  • 0
Posted

Yes, I am using both a background image as well as a logo.  Both images are optimised PNGs from PhotoShop.  I'll try placing the logo on the background image to see if that halves the processing time.  In the meantime, is there a way to extend the PHP max execution time?  I have tried with .htaccess and it is either being ignored or replaced by a directive in a config file.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...