How to open PDF files hosted on Dropbox in a WordPress lightbox popup


Wonder Lightbox 9.4 or above, Wonder PDF Embed 1.8 or above


Wonder Lightbox and Wonder PDF Embed use Mozilla PDF.js to display PDF files. By default, PDF.js only supports PDF files that are hosted on the same domain as the webpage. If your PDF files are hosted on Dropbox, PDF.js will not be able to display them and may show an error "An error occurred while loading the PDF".

The problem is because the Dropbox domain does not support CORS policy, but Dropbox provides a domain that supports CORS by default.

In your Dropbox account, copy the link of the PDF file, change the URL domain from to, change the URL parameter to raw=1, and the link will work in Wonder Lightbox and Wonder PDF Embed.

An online demo is as follows: Open PDF Hosted on Dropbox

The HTML code is as follows:

<a href="" class="wplightbox">Open PDF Hosted on Dropbox</a>