From the Knowledgebase

Error: URL to the PDF file must be on exactly the same domain as the current web page

You will usually see this error in your browser because your PDF does not sit on the same domain as the current page on your site.

For example, if you access the page https://www.example.com/ and see this error message:

Error: URL to the PDF file must be on exactly the same domain as the current web pageCode language: JavaScript (javascript)

or maybe this one:

<em><code>Failed to Fetch</code></em>Code language: HTML, XML (xml)

while retrieving the PDF file at this location: https://example.com/wp-content/uploads/2024/02/file.pdf - this is because the shortcode for the embedded document references the URL on example.com domain whereas the page is sitting on www.example.com.

The www part is important - it references a different domain to the PDF's URL that does not contain www.

For security reasons, browsers are not allowed to load the PDF from a different domain.

Let's say your site is available via both www.example.com and example.com. Then that's an inconsistency that is also confusing to search engines and users.

To fix this, ask your web hosting company to make it consistent - for example, to redirect users directly from www.example.com to example.com, so everyone is using the same domain.

Then, you will need to ensure all your PDF Embedder shortcodes refer to the PDF's URL in the new preferred manner. Various "search and replace" plugins (or the appropriate wp-cli command) may help you to make those changes all over your content.

Sometimes, the problem might be that WordPress is configured to upload PDFs to media.example.com, or something similar, perhaps due to a content-delivery plugin that is attempting to speed up your site. It may still be possible to load PDFs hosted on a different domain, at least if you can set up the configuration of that domain - see Hosting PDFs on other services such as Amazon S3.

It is also possible that a PDF URL is being prevented from loading by a browser Ad Blocker. In the browser console, this shows up as an errorĀ net::ERR_BLOCKED_BY_CLIENT. To fix this, be sure that the PDF file name does not contain any words such as advertisement, advert, ad, ads, click, double-click, and others - which are trigger words for Ad Blockers.

Top