COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Yasser on 12 Jan 2017 03:48:22 AM

Title: How to apply CSS style in PDF
Post by: Yasser on 12 Jan 2017 03:48:22 AM
Hello,

I want to apply some css style in some elements in a report, I've created an HTML item and but my css code inside and created html items before and after the elements which I want to change to specify the css class, Now it is working correctly while running the report as HTML, But when I run it as PDF the styles not applied. This there any workaround to solve this?

Thanks,
Title: Re: How to apply CSS style in PDF
Post by: MFGF on 12 Jan 2017 03:56:17 AM
Quote from: Yasser on 12 Jan 2017 03:48:22 AM
Hello,

I want to apply some css style in some elements in a report, I've created an HTML item and but my css code inside and created html items before and after the elements which I want to change to specify the css class, Now it is working correctly while running the report as HTML, But when I run it as PDF the styles not applied. This there any workaround to solve this?

Thanks,

Hi,

Instead of doing this, go to the Page Explorer and select the Classes area. You can define your own custom class and apply this to anything in the report, using the object's Classes property. It will apply for any rendering types that support formatting (eg HTML, PDF, Excel etc).

Cheers!

MF.
Title: Re: How to apply CSS style in PDF
Post by: Yasser on 12 Jan 2017 04:19:34 AM
Hello,

Many thanks for your response MF,

I've tried this but is is not 100% as I want, there are some properties I don't know how to apply in cognos like (box-shadow: 0 2px 4px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12)) and the border-radius as well.

Is there any way to write the class style as css ?

Title: Re: How to apply CSS style in PDF
Post by: CognosPaul on 12 Jan 2017 03:03:42 PM
The PDF agent Cognos uses does not support CSS3, and many of the modern properties, like box-shadow and border-radius simply will not work. You CAN hack the classes to force those values to be included (open the xml, modify the classes directly), but they'll just be ignored in the PDF. Some things like box shadow can be replicated through clever positioning, but that's dangerous and difficult to support. In some cases I've found it easier to just create images for the background and use that (1 for the top, 1 for the bottom, and a repeating image for the height).
Title: Re: How to apply CSS style in PDF
Post by: Yasser on 15 Jan 2017 08:51:03 AM
Quote from: CognosPaul on 12 Jan 2017 03:03:42 PM
The PDF agent Cognos uses does not support CSS3, and many of the modern properties, like box-shadow and border-radius simply will not work. You CAN hack the classes to force those values to be included (open the xml, modify the classes directly), but they'll just be ignored in the PDF. Some things like box shadow can be replicated through clever positioning, but that's dangerous and difficult to support. In some cases I've found it easier to just create images for the background and use that (1 for the top, 1 for the bottom, and a repeating image for the height).

Great, I will apply the image background Idea.
Thanks Paul,