Troubleshooting Common Complianz mPDF Errors: Proof of Consent & File Generation Issues
Content
Many users of the 'Complianz – GDPR/CCPA Cookie Consent' plugin encounter errors related to its mPDF library, which is responsible for generating Proof of Consent PDF documents. These errors often manifest as fatal errors or warnings in server logs, preventing the plugin from creating necessary files. This guide will help you understand and resolve the most common mPDF-related issues.
Common Error Messages
Based on community reports, the most frequent errors include:
- Fatal error: Uncaught MpdfMpdfException: Unable to create output file – The plugin cannot write the PDF to the specified directory.
- MpdfException: mbstring extension with mbregex support must be loaded – A required PHP extension is missing on the server.
- Warnings about undefined array keys, unserialize(), or font files – Often related to file permissions or server configuration.
- Errors mentioning temporary directories or fonts when using external storage (like S3 buckets) – The mPDF library struggles with non-standard filesystem setups.
Why These Errors Occur
The mPDF library within Complianz requires specific server conditions to function correctly:
- File Permissions: The web server must have write permissions to the
wp-content/uploads/complianz/directory and its subfolders (especiallysnapshots/andtmp/). - PHP Extensions: The
mbstringPHP extension withmbregexsupport is mandatory for mPDF. - Server Configuration: Certain hosting environments, particularly those with external object storage (e.g., S3) for uploads, can interfere with mPDF's need to create temporary files locally.
- Character Encoding: Using non-ASCII characters (like Greek or Cyrillic) in filenames can sometimes cause issues, though this is less common.
Step-by-Step Troubleshooting Guide
1. Verify and Fix File Permissions
The most common fix for "Unable to create output file" errors is ensuring the uploads directory is writable.
- Using an FTP client or your hosting file manager, navigate to
wp-content/uploads/. - Ensure the
complianzfolder exists. If it doesn't, create it. - Inside the
complianzfolder, create a subfolder namedsnapshots. - Set the permissions (CHMOD) for both the
complianzandsnapshotsfolders to 755 or 775. If issues persist, try 777 temporarily to test, but revert to a more secure permission afterward.
2. Install the Required PHP Extension
To resolve the "mbstring extension... must be loaded" error:
- Contact your web hosting provider.
- Request that they enable the
mbstringPHP extension for your account. This is usually done through the hosting control panel (e.g., cPanel) or by modifying thephp.inifile. - Ask them to also ensure
mbregexsupport is enabled within the mbstring extension. - After they enable it, restart your web server (e.g., Apache or Nginx) for the changes to take effect.
3. Check for Conflicting Plugins or Storage
If you use a plugin that offloads media to external storage (e.g., S3):
- mPDF requires a local, writable temporary directory. These plugins can sometimes prevent mPDF from creating its necessary temporary files.
- Temporarily disable any media offloading/CDN plugins and test if the PDF generation works. If it does, you may need to configure an exception for the Complianz directories or seek an alternative setup. The 'Complianz – GDPR/CCPA Cookie Consent' team has previously suggested using the
cmplz_mpdf_argsfilter to customize mPDF's arguments, which could help in such advanced scenarios.
4. Enable Debugging to Get Detailed Errors
If your error message is vague, enable WordPress debugging to get more information:
- Edit your
wp-config.phpfile (always back it up first). - Find the line
define('WP_DEBUG', false);and change it to:define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false); - Save the file and reproduce the error by trying to generate a Proof of Consent snapshot.
- Check the
wp-content/debug.logfile for a detailed error message, which can provide more specific clues. - Remember to disable debugging afterward by setting
WP_DEBUGback tofalse.
When to Seek Further Help
If the steps above do not resolve your issue, the problem might be more complex and specific to your server environment. When seeking help from the community or your host, be prepared to provide:
- The full and exact error message from your logs.
- Your PHP version.
- The version of the Complianz plugin you are using.
- A description of your hosting environment (e.g., standard shared hosting, VPS, cloud platform with external storage).
By systematically checking these common points of failure, most users can successfully resolve mPDF errors and allow the Complianz plugin to generate its important Proof of Consent documents without issues.
Related Support Threads Support
-
Fatal error while creating the mpdfhttps://wordpress.org/support/topic/fatal-error-while-creating-the-mpdf/
-
Mpdf temp directoryhttps://wordpress.org/support/topic/mpdf-temp-directory/
-
Error when trying to generate proof of consent documenthttps://wordpress.org/support/topic/error-when-trying-to-generate-proof-of-consent-document-2/
-
MpdfMpdfException: Unable to create output filehttps://wordpress.org/support/topic/mpdfmpdfexception-unable-to-create-output-file/
-
Typo in Plugin Filename – complianz-gpdr.phphttps://wordpress.org/support/topic/typo-in-plugin-filename-complianz-gpdr-php/
-
problems with generate_cookie_policy_snapshothttps://wordpress.org/support/topic/problems-with-generate_cookie_policy_snapshot/
-
huge error log file containing continuous php warnings of complianz-gdpr-premiuhttps://wordpress.org/support/topic/huge-error-log-file-containing-continuous-php-warnings-of-complianz-gdpr-premiu/
-
Multiple errors on Complianz (WP-CRON)https://wordpress.org/support/topic/multiple-errors-on-complianz-wp-cron/
-
Automatically generated snapshotshttps://wordpress.org/support/topic/automatically-generated-snapshots/
-
Problems with Mpdf when generating documents via cronhttps://wordpress.org/support/topic/problems-with-mpdf-when-generating-documents-via-cron/
-
proof of consent don’t generate pdfhttps://wordpress.org/support/topic/proof-of-consent-dont-generate-pdf/
-
PHP Warnings in log filehttps://wordpress.org/support/topic/php-warnings-in-log-file/
-
PHP Fatal error: Uncaught MpdfMpdfException: Unable to create output filehttps://wordpress.org/support/topic/php-fatal-error-uncaught-mpdfmpdfexception-unable-to-create-output-file/