如何在javascript中找出打印纸的维度 [英] How to find out the dimensionality of print paper in javascript

查看:115
本文介绍了如何在javascript中找出打印纸的维度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在生成HTML格式的报告,并希望使用Qt自动打印它们(qt有一个基于webkit的浏览器,可以将其内容呈现为PDF文件)。
我想根据目标页面大小定位报告的元素。
为此我需要访问论文的大小(最好以像素为单位)。

I am generating reports in HTML formats, and want to print them automatically using Qt (qt has a webkit based browser, and one can render its contents to a PDF file). I want to position the elements of the report depending on the target page size. For that i need to access the size of the paper (preferably in pixels).

由于我使用的是webkit,它拥有所有最新的html5和css3功能。

Since i am using webkit, it has all the latest html5 and css3 features.

是否有一些api可用于访问javascript中的打印页面属性。例如,写起来会很好:
window.print_paper.width或window.print_paper.height

is there some api available to access printed page properties inside javascript. for example, would be nice to write: window.print_paper.width or window.print_paper.height

提前谢谢

推荐答案

你要求的是 standards-track @page spec 。 CSS3分页媒体(@page)允许您执行的操作是指定应在其上打印文档的方向和页面大小 - 而不是在系统中查询当前选定的方向和页面大小。据我所知,即使是CSS3媒体查询内容也不允许你这样做。

What you're asking for is backwards from the standards-track @page spec. What CSS3 paged media (@page) allows you to do is specify an orientation and page size that your document should be printed on - not query your system for the currently selected orientation and page size. Even the CSS3 media query stuff won't allow you to do this, to the best of my knowledge.

这篇关于如何在javascript中找出打印纸的维度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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