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…
configuration.phpfile which is located in the
- If your template uses large tables, you can set
- Another option is to set
truewhich 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 –
truewill 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
truewhich will only load the bare minimum features. Along with the features disabled by enabling
PDF_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