2

CSS:

table.print{
    width:123px;
    height:298px;
    background-position:center;
    background:url('{{ STATIC_URL }}images/human.png'); 
}

HTML:

<table id="human-body" class="print" >
    <tr>
        <td>some data</td>
    </tr>
</table>

The above HTML is used as a print template in django in my app. My problem is, I used the above CSS to apply the background image to the print page. But if I press print button and see the print preview the background image is missing. I checked with printing it in paper also,the image is missing.

arulmr
  • 8,620
  • 9
  • 54
  • 69
user2086641
  • 4,331
  • 13
  • 56
  • 96

2 Answers2

1

If you are looking to print background image,then follow the below steps

1.To enable background printing in Chrome and Safari web browsers add

-webkit-print-color-adjust:exact;

in your print.css file,rest all is same

2.In FireFox by default "Print Background colours and images" turned off in their print settings,no CSS will override that.

User should manually turn on if background image is required.

Steps for turn on background in FF:

Go to File -->Page setup -->Formats & Options -->Tick Print background(images & colors)
Community
  • 1
  • 1
user2725407
  • 400
  • 1
  • 4
  • 16
  • Late answer,I solved it also refer this thread http://stackoverflow.com/questions/11242991/how-to-forcefully-print-background-image-in-html – user2086641 Oct 16 '13 at 13:33
0

You can't use STATIC_URL in css files. You can only use it in template.

Silwest
  • 1,620
  • 1
  • 15
  • 29