42
Views
5
Comments
[Html2PdfConverter] Images and Styles are not loading in Html2PdfConverter PDF
html2pdfconverter
Web icon
Forge asset by Guilherme Pereira
Application Type
Traditional Web
Service Studio Version
11.54.64 (Build 63346)

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

2023-12-16 19-57-03
Sanjay Kushwah

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 



UserImage.jpg
Vishnu shankar

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. 


Thanks & Regards

Vishnu shankar

2023-12-16 19-57-03
Sanjay Kushwah

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.


UserImage.jpg
Vishnu shankar


I added my personal environment URL to the specified directives, but the styles and images are still not loading.


2023-12-16 19-57-03
Sanjay Kushwah

Could you try with * it means allows all origins of the resource type.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.