如何在网页中打印图像,适合纸张尺寸(A3,A4,A5等)? [英] How can I print an image in a web page, fitting the paper size (A3, A4, A5, etc)?

查看:6265
本文介绍了如何在网页中打印图像,适合纸张尺寸(A3,A4,A5等)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用IE9和媒体查询,我不需要从其他浏览器工作。

I am currently using IE9 and media queries and I have no need to have this working from other browsers.

我尝试使用一组规则:

@page {
    size: auto;
    margin: 10mm 10mm 10mm 10mm;
}

// ...匹配所有A格式的毫米A0,A1,A2等)包括边距和容差。

//... rules to match the millimiters of all the A formats (A0, A1, A2, etc) including margins and tolerance

/* A4 210x297 mm */
@media print and (min-height: 266mm) and (max-height: 288mm) and
    (min-width: 179mm) and (max-width: 201mm) {
    .img_port {
        height: 267mm !important;
    }
}

// ...

似乎是工作,但它是不可靠的,因为传递到CSS的大小高度和宽度值似乎取决于打印机,即使总是选择A4格式。

it seems to be working but it is not reliable because the size height and the width values passed to the CSS seems to depend on the printer even if the A4 format is always selected.

我想问的是,如果有其他可能的方法获得相同的结果(根据纸张大小在一页上拟合图像)。

What I want to ask is if there is any other possible way to obtain the same result (fitting the image on one page according to the paper size).

提前谢谢。

推荐答案

IE中打印的长短都是无法准确控制这种情况。

The long and short of printing in IE is that you will never be able to accurately control things like this.

物理上,打印机在页面有多少可打印区域时具有不同的功能。然后,您还必须处理IE从用户打印的最后一页(例如缩放,页边距,每页页面等)记住的任何设置。

Physically, printers have different capabilities when it comes to how much of the page is printable area. Then, you also have to deal with any settings that IE remembers from the last page the user printed such as zoom, margins, pages-per-page, etc.

这个多年来,我终于放弃了试图控制IE的打印页面,并开始处理我的打印样式表更像建议。

After struggling with this for years, I have finally given up attempting control of what IE does with print pages and started treating my print stylesheets more like suggestions.

IE< 9简单地不以任何有意义的方式支持分页符或@page,并且在我的测试中,IE9只是忽略几乎所有的@page规则,以支持用户最后配置的任何设置。

IE < 9 simply does not support page-break or @page in any meaningful way and, in my testing IE9 simply ignores almost all @page rules in favor of whatever settings the user last configured.

要建议IE在网页的全宽和整个高度打印图片,请尝试解答 Landscape从HTML打印

To suggest that IE print an image at the full width and full height of the page try the answer Landscape printing from HTML

这篇关于如何在网页中打印图像,适合纸张尺寸(A3,A4,A5等)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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