从HTML横向打印 [英] Landscape printing from HTML

查看:2393
本文介绍了从HTML横向打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML报告,需要打印横向,因为许多列。有没有方法可以做到这一点,用户不必更改文档设置?

I have a HTML report, which needs to be printed landscape because of the many columns. It there a way to do this, without the user having to change the document settings?

浏览器之间的选项是什么。

And what are the options amongst browsers.

推荐答案

在你的CSS中,你可以设置@page属性如下所示。

In your CSS you can set the @page property as shown below.

@media print{@page {size: landscape}}

@page是 CSS 2.1规范,但这个 size 不是由问题是@ page {size:landscape}已过时吗?

The @page is part of CSS 2.1 specification however this size is not as highlighted by the answer to the question Is @Page { size:landscape} obsolete?:


CSS 2.1不再指定size属性。 CSS3分页媒体模块的当前工作
草稿确实指定它(但不是
标准或接受)。

CSS 2.1 no longer specifies the size attribute. The current working draft for CSS3 Paged Media module does specify it (but this is not standard or accepted).

如上所述,尺寸选项来自 CSS 3草图规格< a>。在理论上,它可以设置为页面大小和方向,尽管在我的示例中大小被省略。

As stated the size option comes from the CSS 3 Draft Specification. In theory it can be set to both a page size and orientation although in my sample the size is omitted.

支持非常混合与错误报告开始在firefox 提交,大多数浏览器不支持它。

The support is very mixed with a bug report begin filed in firefox, most browsers do not support it.

它似乎可以在IE7中工作,但这是因为IE7会记住用户上次选择横向或纵向在打印预览(只有浏览器重新启动)。

It may seem to work in IE7 but this is because IE7 will remember the users last selection of landscape or portrait in print preview (only the browser is re-started).

本文有一些建议的工作,使用JavaScript或ActiveX向用户浏览器发送密钥,虽然它们不理想,并依赖于更改浏览器安全设置。

This article does have some suggested work arounds using JavaScript or ActiveX that send keys to the users browser although it they are not ideal and rely on changing the browsers security settings.

或者,您可以旋转内容而不是页面方向。这可以通过创建一个样式并将其应用于包含这两行的主体来完成,但是这也会产生很多对齐和布局问题。

Alternately you could rotate the content rather than the page orientation. This can be done by creating a style and applying it to the body that includes these two lines but this also has draw backs creating many alignment and layout issues.

<style type="text/css" media="print">
    .page
    {
     -webkit-transform: rotate(-90deg); 
     -moz-transform:rotate(-90deg);
     filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
    }
</style>

我找到的最后一个选择是在PDF中创建一个横向版本。当用户选择打印时,您可以指向打印PDF。但是我无法在IE7中自动打印工作。

The final alternative I have found is to create a landscape version in a PDF. You can point to so when the user selects print it prints the PDF. However I could not get this to auto print work in IE7.

<link media="print" rel="Alternate" href="print.pdf">

总而言之,在某些浏览器中,使用@page size选项相对容易,但在许多浏览器中没有确定的方式,它将取决于你的内容和环境。
这可能是为什么当选择打印时,Google文档创建一个PDF,然后允许用户打开和打印。

In conclusion in some browsers it is relativity easy using the @page size option however in many browsers there is no sure way and it would depend on your content and environment. This maybe why Google Documents creates a PDF when print is selected and then allows the user to open and print that.

这篇关于从HTML横向打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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