Using the LifterLMS PDFs Image Proxy Server
LifterLMS PDFs includes an image proxy server utilized by the included client-side PDF generation utilities.
This advanced setting is necessary for exporting certificates as PDFs if you are including images hosted on a different domain that the website where the LifterLMS PDFs add-on is installed.
If you’re not sure whether or not your site requires the Image Proxy to be enabled you can follow these steps:
- Ensure that certificate exports are enabled and the image proxy is disabled in your LifterLMS PDFs settings
- Visit a certificate template or earned certificate on the frontend of your website
- Click the Save button to download a PDF of the certificate
If you are able to successfully download the certificate your site doesn’t require an image proxy. If, however, you encounter the following error message:
An error was encountered during PDF generation. [SecurityError] Failed to execute ‘toDataUrl’ on ‘HTMLCanvasElement’: Tainted canvases may not be exported.
Then you will need to enable the image proxy.
To configure the image proxy server, head to the LifterLMS PDFs settings and locate the Image Proxy section.
Check the box that says Enable Image Proxy.
You should also configure the list of Allowed Origins. This is a list of full or partial domain names (origins) which you wish to explicitly allow to utilize the Image Proxy server. When configuring your list, enter one full or partial domains per line.
If you wish to allow any origin to use the Image Proxy, simply enter “*” (a wildcard) as the only entry in the list. Note that using this configuring could introduce a security and/or performance risk to your site so we recommend to only use a wildcard if you’re unable to adequately generate a complete allow list.
When entering domains we recommend using a fully-qualified domain name for each origin, for example, if you wished to allow images from lifterlms.com
, you should enter https://lifterlms.com
. This isn’t required though and there may be circumstances in which you wish to enter only lifterlms.com
. If you wish to allow images regardless of protocol, you could enter ://lifterlms.com
which would allow images from either https://lifterlms.com
or http://lifterlms.com
.
After enabling the proxy and Allowed Origins list, save your settings and try to export your certificate again. If you configured it correctly the error you previously experienced will go away and your certificate will be exported successfully.
If you’re not sure what origins are being used on your website you can follow these steps to help generate a list:
- Visit a certificate on the frontend of your website.
- Open the browser’s developer tools (Using Chrome, Using Edge, Using Firefox)
- Click on the Network Tab and then filter requests by Img
- Reload the page
- View the resulting list of images by clicking on each one
Any image from a domain name other than your website’s domain is a domain you likely need to add to your allow list.