TCPDF Performances

If you want to use EDDiMark or WaterWoo with WordPress on your server, it’s really important that you TUNE your server so that it can handle the load. There are a lot of factors to account for if you are getting errors while watermarking. Some people bring huge PDFs, some people bring complex PDFs, some people bring complex watermarks, some people bring traffic spikes, some servers bring down time, some people bring a mix of all those factors. The best way to get reliable watermarking is by tuning your setup and performing initial and periodic testing of the setup.

Below are the original recommendations for “performances” of TCPDF (it came down off the web in late 2020 but is still available in the WayBack Machine). I have annotated them for clarification

  • 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 (not really necessary)
  • If you are not using the Thai language, edit the config/tcpdf_config.php file and set the K_THAI_TOPCHARS constant to false (this is done by default in Little Package plugins)
  • 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 (helvetica, times, courier) instead of embedded fonts whenever possible
  • Avoid using the HTML syntax (writeHTML and writeHTMLCell methods) if not strictly required (Little Package plugins try to avoid using writeHTML/writeHTMLCell where possible)
  • Split large HTML blocks in smaller pieces
  • Avoid using transactions if not strictly required (This really won’t apply to most applications using the Little Package plugins)
  • Restart the webserver after server setup changes