Version: 3
🔥 Gravity PDF v3 end of life was 2017-06-20 and this version is no longer supported. This legacy documentation is kept for reference only.
Memory Problems
Gravity PDF is very memory intensive and it isn't uncommon to have memory issues on shared hosting services. The best way to solve memory issues is to increase memory to the recommended 128MB but this isn't always possible.
Things you can do...
Note: All the following constants are located at the bottom of the
configuration.php
file which is located in the PDF_EXTENDED_TEMPLATES
folder.- If your template uses large tables, you can set
PDF_ENABLE_SIMPLE_TABLES
totrue
. - Another option is to set
PDF_DISABLE_FONT_SUBSTITUTION
totrue
which will embed the full font file directly into the PDF. This has the negative impact of increasing the PDF's total size, but will keep memory down. PDFs displaying only English characters can negate this effect by setting the font to one of the defaults -Arial
,Times
, orCourier
. - Setting
PDF_ENABLE_MPDF_LITE
totrue
will strip out some of the more advanced features from the package such as complex table borders, terms and conditions, columns, index, bookmarks and barcodes. - As a last resort you can try set
PDF_ENABLE_MPDF_TINY
totrue
which will only load the bare minimum features. Along with the features disabled by enablingPDF_ENABLE_MPDF_LITE
, there's no positioning, float, watermark or form support.
You should also keep in mind the following when creating your template files.
- If using images the best format is JPG, followed by PNG files that aren't interlaced and have no alpha channel. Keep away from GIF files and interlaced or alpha channel PNGs as they require a lot more memory to process.
- Limit the number of fonts used - try stick to one. If you can, you should use the base PDF fonts - Arial, Times, or Courier - which don't need to be embedded into the PDF. Note: the base fonts have limited support for non-Western European languages.
- Instead of using HTML attributes to format the PDF you should use CSS styles.
- Don’t use the CSS property “overflow” as it will slow down the PDF generation time