Support Article

Custom styles defined in CSS do not get passed to PDF



User has a non-autogenerated section to generate a label with bar codes on the screen.The label is shown appropriately on the screen and the same label have to be exported to PDF. HTMLTOPDF activity is used to generate the PDF. The custom styles do not get reflected in the generated PDF. 

Error Messages

Not Applicable. 

Steps to Reproduce

1) Create a non-autogenerated section
2) Add your own custom HTML code.
3) Add the styles to a CSS file.
4) Refer the CSS file in the non auto generated section using <link rel or pega:static JSP tags.
5 ) In an activity first step set property-set-stream and specify the above created section.
6) Get the HTMl content in to a param or a loca variable.
7) Pass it to the HTMLTOPDF activity.
8) Use code-pega-pdf.view activity to view the PDF that is generated.

Root Cause

The root cause of this problem is that the link tag for the CSS mentioned in the HTML code is not being referred and picked. The CSS link tag is read directly without reaching the reference CSS file as follow:-


This issue is resolved by directly mentioning the CSS code in the HTML instead of referencing using the link tag.
Suggest Edit

Published January 31, 2016 - Updated October 8, 2020

Did you find this content helpful?

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.