PDF Embedder Documentation

Documentation, Reference Materials, and Tutorials for PDF Embedder

Get access to
Powerful Features!

Home » Documentation » Troubleshooting Errors » Fixing Invalid PDF Structure Error

Fixing Invalid PDF Structure Error

Seeing an “Invalid PDF Structure” error where a PDF should be displaying? This error typically occurs due to a server configuration problem. Either the encrypted PDF file isn’t being streamed correctly to the browser (often because gzip compression is being applied incorrectly to the file), or the decryption key stored in the browser is stale and no longer matches the server’s current key.

This guide walks through the options to help you resolve the error in PDF Embedder.


Reloading the Page

This is the first thing you should try when faced with this error. Since the error can appear as a one-off caused by a temporary network hiccup or an expired browser state, try reloading the page and checking whether the PDF displays correctly. If it does, no further action is needed.

Clearing Your Cache

A stale cache also causes the browser to receive an outdated or mismatched decryption key, which can result in this error. You should clear the cache at two levels:

  1. Purge all cached files through your caching plugin (WP Super Cache, W3 Total Cache, WP Rocket, LiteSpeed Cache, or whichever you use).
  2. Clear your browser cache, then do a hard reload (Ctrl + Shift + R on Windows, Cmd + Shift + R on Mac).

Excluding PDF Embedder Scripts from Caching

If the error returns after every page load, your caching or minification plugin is most likely the cause. PDF Embedder’s scripts are already minified, so excluding them costs nothing in load speed. You should exclude PDF Embedder assets from any caching or minification options on your site.

After adding these exclusions, flush all caches (including any JS-specific caches) and reload.

Checking for Gzip Compression on PDF Files

If the error persists after clearing the cache and excluding the scripts, the likely cause is gzip compression being applied to the PDF file itself at the server level. Gzip compression on PDFs corrupts the encrypted stream before it reaches the browser.

In this case, you need to add an exception in your server configuration to exclude PDF files from gzip compression as shown below:

Apache or LiteSpeed (.htaccess):

<IfModule mod_deflate.c>
  SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
</IfModule>
Code language: HTML, XML (xml)

Nginx:

location ~* \.pdf$ {
    gzip off;
}

Caddy:

@pdf path *.pdf
encode @pdf {}
Code language: CSS (css)

After adding the configuration, flush all caches and test again. If you’re not comfortable editing server configuration files, we recommend that you contact your hosting provider and ask them to exclude PDF files from gzip compression.

Testing with a Different PDF

If all the above options do not work for you, you can try embedding a different PDF document. If the second file loads without error, the thisconfirms that original PDF may be corrupted. Open the original file in Adobe Acrobat and re-export it, or try recreating it from the source document.

Getting Further Help

If none of these steps resolve the error, contact support with the URL of the page showing the error and the name of your hosting provider.

Still have questions? We’re here to help!

Last Modified: