158
Views
5
Comments
[Html2PdfConverter] The component is blocking some css while generating pdf.
html2pdfconverter
Web icon
Forge asset by Guilherme Pereira

Hello team,

 I have requirement to display images and column chart in pdf report with fixed column size and fixed image placeholder. If the image resolution doesn't matches with placeholders resolution it should reflected in inside that placeholder.

I made perfect replica of what i want and what i'm getting here.

Can some one help me with this?..


Thanks in Advance,

Regards, Kiran Shinde.

2017-12-13 08-27-28
Joey Moree

I see, it has nothing to do with the Html2PdfConverter though, but instead relies on the styling the printer receives.
Try pressing CTRL+P on the page, this is what the printer sees (also what Html2PdfGenerator sees).
You can fix the color issue by adding:
-webkit-print-color-adjust: exact

To the elements which are not showing the background color, but you might be able to come further if you use a CSS file instead of inline styling.

UserImage.jpg
Vitor David

Hey there Kiran, sorry for the non-answer about your query. But i got a problem that it seems you managed to do it, how did you export the bar chart to pdf? Any advanced format flag that i missed? Thanks in advanced

2024-08-28 10-01-54
Kiran Shinde

Hello Joey Moree,

Sorry for late reply, As you said i haven't applied css thorough inline you can see in attachment OML.

PdfTest.oml
2017-12-13 08-27-28
Joey Moree

Hey Kiran,

I've looked a bit more into it, it seems to be a known problem!

The reason this happens is because the background colors and images are ignored in printing! Luckily you have 2 options to force the printing of colors and images, 1 is to set the printBackground option to true.

printOptions: {
      printBackground: true,
  }

The other options is to add -webkit-print-color-adjust: exact; To your body tag (or the specific tags where you need the background to appear).

2024-08-28 10-01-54
Kiran Shinde

Joey Moree wrote:

Hey Kiran,

I've looked a bit more into it, it seems to be a known problem!

The reason this happens is because the background colors and images are ignored in printing! Luckily you have 2 options to force the printing of colors and images, 1 is to set the printBackground option to true.

printOptions: {
      printBackground: true,
  }

The other options is to add -webkit-print-color-adjust: exact; To your body tag (or the specific tags where you need the background to appear).

I did what you said but its not working. can you attach a working demo. 

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