如何打印与背景图片的网页? [英] How to print webpage with background image?

查看:110
本文介绍了如何打印与背景图片的网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打印一个网页的形式在IE与背景图像;现在的问题是,它没有显示在其印刷背景图像。有没有办法解决它,因为我试过很多技巧,但他们都不是实际工作。如果你的任何一个之前固定它,请分享一下。

I'm trying to print a web page form in IE with a background-image; now the issue is that it is not showing background-image in its print. Is there a way to fix it because I tried lots of tricks but none of them are actually working. if any one of you fixed it before please share.

推荐答案

这仅仅是人谁可以尝试花了很多时间来打印CSS背景图像。
这可能不是100%的工作,但你可以从这里挑选。

This is just for people who may try to spend a lot of time to print css background images. This may not be 100% working, but you may pick from here.

解决方案:不可能(如果重叠图像在UI present)

Solution: not possible (if overlapping images are present in UI)

 $('#rootdiv').find('div').each(function(){
    if( $(this).css("background-image") !=  "none"){

        $(this).css("overflow" ,"hidden").css("position", "relative");
        $(this).prepend('<img style="display: block;position: absolute;" src="'+$(this).css("background-image").replace(/"/g,"").replace(/url\(|\)$/ig, "")+'">');

        $(this).css("background",'..');

    }
 });

PS:对于已经切片的一半图像打印在页面上,我们需要设置一个宽度为格(即$(本))小于背景图像的实际宽度(由src中动态创建的img标签上面指定),它会显示切片图像

P.S.: To have sliced half image print on the page, we need to set a width for the div ( i.e., $(this) ) less than actual width of background-image( specified by src in dynamically created img tag above) , it will show sliced image

这篇关于如何打印与背景图片的网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆