ASP.net中的A4大小窗口 [英] A4 size window in ASP.net

查看:180
本文介绍了ASP.net中的A4大小窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打开一个新页面,该页面将被视为包含一些内容的打印预览窗口。我正在使用window.open方法给它一些大小。我需要这个窗口是A4大小的风景/肖像(根据用户选择)。用户以后可以使用浏览器的打印容量进行打印。我在如何根据像素决定这个窗口尺寸方面遇到了困难,我认为屏幕分辨率在这里也扮演了一些角色。可能很容易,但无法弄明白。任何人都可以指导。



谢谢,



Vijay

解决方案

不,这不容易。问题是:页面不是以厘米或英寸为单位测量的,因此不能是A4或Letter尺寸。整个想法都错了。页面的大小取决于用户如何看待它,用户计算机的屏幕像素尺寸以及用户选择的浏览器窗口大小和放大率。假装它是别的东西,并试图模仿不同的行为将违背Web的性质。



毕竟,如果你需要精确的打印输出,请动态制作PDF文件并提供用户打印它。不要尝试打印页面,打印正确格式化的数据以进行打印。要准备此类PDF文档,请使用iTextSharp库,请参阅 http://sourceforge.net/projects/itextsharp/ [ ^ ]。



-SA

I want to open a new page which will be considered as a print preview window with some content. I am using window.open method giving it some size. I need this window to be of A4 size landscape/portait (as per users selection). The user can later use browser's print capacity to print. I am having difficulty on how to decide the this windows size in terms of pixels and I assume screen resolution also plays some role here. Probably something easy but could not figure it out. Can anyone guide please.

Thanks,

Vijay

解决方案

No, it's not something easy. The thing is: a page is not measured in centimeters or inches, so it cannot be A4 or Letter size. The whole idea is wrong. The size of the page depends on how the user looks at it, screen pixel dimensions of user computer and user-selected browser window size and magnification. Pretending it's something else and trying to mimic different behavior would be against the nature of Web.

After all, if you need exact printout, make a PDF file on the fly and offer the user to print it. Don't try to print the page, print your data properly formatted for printing. To prepare such PDF document, use iTextSharp library, see http://sourceforge.net/projects/itextsharp/[^].

—SA


这篇关于ASP.net中的A4大小窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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