2

I have a problem printing background images and bgd colors in html in views and custom blocks. For example, when I add HTML code with CSS classes into a custom block (class has bgd image or bgd color style) it is shown on the html page in browser, but not in print preview (print backgrounds is off). Same thing is with the custom html code defined for view field (I created a link field and rewrite output)

Normally HTML code, defined out of blocks and views is, showing both bgd colors and images in print preview even if print background option is turned off in browser. All CSS styles are defined in one file.

For some reason browser is not reading CSS styles within blocks and views.

closed as off-topic by Елин Й., Mołot, Shawn Conn, Adrian Cid Almaguer, Krishna Mohan Feb 1 '16 at 13:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on programming, PHP, SQL, etc. that do not relate directly to Drupal are off-topic here, but can be asked on Stack Overflow." – Елин Й., Mołot, Shawn Conn, Adrian Cid Almaguer, Krishna Mohan
If this question can be reworded to fit the rules in the help center, please edit the question.

0

Sorry if I haven't understood correctly, but it sounds like you're asking why backgrounds aren't printed when 'Print Backgrounds' is off?

That's a browser setting and is down to the user. If that option is disabled, background images and colours should not be printed as far as I'm aware. So what you're seeing is the correct/expected behaviour.

For webkit browsers you can try -webkit-print-color-adjust with the exact setting, i.e.

-webkit-print-color-adjust: exact;

That should force the background to be printed for the element regardless of the user's setting

Background colors and images of the element to which this rule is applied are always printed, user's print settings are overridden.

  • Thank you for your reply, I understand that is a browser setting but the main problem is that same class (with background images and colors) is shown in print preview (print background is off) for some the blocks on homepage. In fact styles are shown for all elements except the one who are defined in block or view code. For example: I made a new block with existing class code <p class="eclass"></p> eclass have bgd styles. Same p element bgd styles are visible in browser but not in print preview. But, in similar styles in other block elements (not custom) bgds are shown in print preview. – user12255 Dec 23 '12 at 14:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.