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

Start here. The error can be a one-off caused by a temporary network hiccup or an expired browser state. Reload the page and check whether the PDF displays correctly. If it does, no further action is needed.

Clearing Your Cache

A stale cache can deliver an outdated or mismatched decryption key, producing this error. Clear the cache at two levels:

  1. Purge all cached files through your caching plugin
  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 on every page load, your caching or minification plugin is likely the culprit. PDF Embedder’s scripts are already minified, so excluding them costs nothing in load speed.

Exclude PDF Embedder assets from all caching and minification rules on your site. After adding the exclusions, flush all caches, including any JS-specific caches, then reload the page.

For the exact file paths to exclude based on which version of the plugin you are using, see our Using Caching or Minifying Plugins guide.

Checking for Gzip Compression on PDF Files

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

Add an exception to your server configuration to exclude PDF files from gzip compression:

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 are not comfortable editing server configuration files, contact your hosting provider and ask them to exclude PDF files from gzip compression.

Testing with a Different PDF

If none of the above steps work, embed a different PDF file and check whether the error persists. If the second file loads without error, the original PDF is likely corrupted. Open it in Adobe Acrobat and re-export it, or recreate it from the source document.

If the error only appears in Microsoft Edge and not in other browsers, the web server may be redirecting PDF file requests to your homepage instead of serving the actual file. Test this by entering the PDF URL directly into the Edge address bar. If it redirects you to your homepage rather than downloading or displaying the file, the server is not serving it correctly.

The most common cause is hotlink protection. Check your cPanel settings and either disable hotlink protection or configure it to allow direct URL access for PDF files. Once the server serves the file correctly, the error will not appear.

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: