Hi everyone,
I recently encountered an issue where images and style contents were not loading in downloaded PDFs after enabling CSP settings. We are using the Html2PdfConverter component for PDF downloads.
Please help on this and provide the correct header values for the CSP settings.
Thanks & Regards
Vishnu Shankar
Hi @Vishnu shankar,
Actually, CSP prevent to load resources from external site. so, when you give URL of your PAGE (that page needs to generate the pdf), it will take it as external site and will not load resources, Same think also happens with iframe implementation. Then there are some changes required in CSP setting,
please check this Video (allow ifram to load resources from URL): Using iFrame in OutSystems applications (youtube.com)
Hopefully same CSP should also work for load the styling of your page. and also read CSP documentation for better understanding.
Apply Content Security Policy - OutSystems 11 Documentation
Hope this will help you.
Kind regards,
Sanjay Kushwah
Hi @Sanjay Kushwah,
Thanks for your response. I understand what you're saying, but I'm unable to find the correct URL for the CSP setting to load the resources.
Vishnu shankar
actually, you don't have need to change URL,
Just you need to configure correct CSP setting in your environment.
when you enable CSP setting in lifetime, here will be some inputs where you need to provide correct values,
for example in connect-src in the description is: Specifies the domains from which the application can load resources using script interfaces. The following source expressions are allowed: 'self' and *
it means you can set value is Script allow from other sources or not if you give value * then it means script will allow from anywhere and if you give value self it means you can load resources only from your domain directories.
I added my personal environment URL to the specified directives, but the styles and images are still not loading.
Could you try with * it means allows all origins of the resource type.