Skip to main content
Version: v6

HTTP Error 404 for /initialisation/template.css

If you begin seeing a 404 error message for a /gravity-pdf/initialisation/template.css file when viewing PDFs then you've been using Gravity PDF for a looong time (congratulations)! This CSS file was shipped in Gravity PDF v3, but was deprecated in the v4 release (2016), and finally removed from the plugin in v6 (2019).

This problem is simple to hide, but we highly recommended you complete all the maintenance steps to fix the root cause of the issue and help future-proof your PDFs.

warning

Create a backup of your website before attempting any changes. Should something go wrong you can easily restore your backup.

Mask the Error

In the Gravity PDF v6.13 update, the PDF engine’s asset loader (CSS and images) got an upgrade and this is now tied into WordPress’ debug mode. When debug mode is enabled and a PDF is generated, asset-loading errors will be displayed to administrators on-screen – instead of being silently ignored. To turn off this developer feature you will need to edit your site’s wp-config.php file and either disable WordPress debug mode or hide errors from displaying.

Disable debug mode entirely (recommended in production environments):

define( 'WP_DEBUG', false );

Or keep debug mode enabled, but hide errors and warnings on screen:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );

Importantly, if your wp-config.php file already has these lines don’t add additional copies of them. Replace/modify the existing lines.

After making this change, check your PDF will now generate from the Entry List page.

Fixing the Error

HTTP error “404” for https://xxxxxxxxxx.com/wp-content/plugins/gravity-pdf/initialisation/template.css in public_html/wp-content/plugins/gravity-pdf/src/Helper/Mpdf/Request.php on line 79

If the template.css file no longer exists why is something trying to load it? It's caused by your legacy custom PDF template(s) stored in the PDF Working Directory.

In the Gravity PDF v5 to v6 Migration Guide, one of the recommended steps is to update any custom PDF template(s) and either remove reference to the template.css file, or inline the styles. Since you hadn’t noticed any display issues in your PDF before now, it would be safe to remove the reference entirely.

The code you need to take out probably looks like this:

<link rel='stylesheet' href='<?php echo PDF_PLUGIN_URL .'initialisation/template.css'; ?>' type='text/css' />

On a standard installation, you’ll find the PDF Working Directory at /wp-content/uploads/PDF_EXTENDED_TEMPLATES/ on the server (but it can be moved). You should review each template in this directory and remove this reference.

Other Maintenance

To help you future-proof your installation, here are a couple of items from our upgrade guides that you might have missed over the years.

Outdated Core Templates

In the v6 release, the four Core templates – Zadani, Focus Gravity, Rubix, and Blank Slate – were updated to support Drag and Drop columns. As you've likely run the Setup Template Tool, your Core template overrides will be out of date and need to be updated (or deleted). You can check if you're affected by looking for a section called "Outdated Templates" on the System Status page.

If you are using an out-of-date version of the Core templates, there are two ways you can fix the problem:

  1. If you haven't made any modifications to the Core template(s), you can delete those template files via the PDF Template Manager.
  2. If you did modify a Core template, you will need to merge in all the new changes for these templates with your template overrides in the PDF Working Directory. To make this easier, copy the template code into a diff tool and compare the changes.

Audit Your Custom Templates

Over the years the custom template structure has evolved and been simplified. It's recommended you audit your custom templates and make sure they follow the latest structure. If your custom templates are copies of a Core template, you can compare them to the latest Core template code. If you've custom templates that you don't use, consider deleting them.