Performances
To optimize the performance of the Ultimate PHP PDF Generator Engine and ensure efficient operation, especially for complex or large document generation, we recommend following these configuration best practices based on TCPDF standards:
Server-Level & PHP Configuration:
-
Implement Opcode Caching: For significant performance gains, install and configure a PHP opcode cacher such as XCache.
-
Adjust Memory Limits: Increase the PHP
memory_limitin yourphp.inifile to allow scripts sufficient memory for generation. -
Extend Execution Time: Increase the PHP
max_execution_timeinphp.inito prevent scripts from timing out during lengthy processes.
Engine-Specific Configuration (config/tcpdf_config.php):
-
Manually Set Crucial Paths: Improve path resolution speed and reliability by manually defining the
$_SERVER['DOCUMENT_ROOT'],K_PATH_MAIN, andK_PATH_URLconstants inconfig/tcpdf_config.php. Remove the automatic calculation logic for these paths. -
Disable Unused Features:
-
If Thai language support is not required, set the
K_THAI_TOPCHARSconstant tofalse. -
If your documents do not need extended characters, set the default fonts to core fonts for smaller file sizes.
-
If UTF-8 Unicode support is unnecessary, configure the TCPDF constructor by setting the
$unicodeparameter tofalseand the$encodingparameter to an alternative character map (e.g.,'ISO-8859-1').
-
Generation Best Practices:
-
Manage Font Subsetting: While font subsetting reduces the size of embedded Unicode TTF fonts, it is a memory-intensive and slower process. If performance is critical, consider turning it off using the
setFontSubsetting(false)method. -
Prioritize Core Fonts: Use standard core fonts instead of embedded fonts whenever possible to reduce processing time and file overhead.
-
Optimize HTML Usage:
-
Avoid using complex HTML syntax (
writeHTMLandwriteHTMLCellmethods) unless absolutely necessary. -
If you must use large blocks of HTML, split them into smaller, manageable pieces to optimize rendering.
-
-
Avoid Unnecessary Transactions: Use database transactions only when strictly required during PDF generation to reduce system load.
Crucial Step: Always restart your web server (e.g., Apache, Nginx) after making any changes to php.ini or configuration files for the optimizations to take effect.