打印页面不显示呢? [英] Printing a page without displaying it?

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

问题描述

我从中用户将能够为打印的页面。然而,这将让打印的页面不是用户正在浏览的人,而是一个新的,我想生成的背景和(可能)只显示它的打印对话框。

I have a page from which the user will be able to print. However, the page which will get printed is not the one the user is viewing, but rather a new one I'd like to generate on the background and (possibly) only show the print dialog for it.

只是为了把事情说清楚:

Just to make things clear:


  1. 用户是在 View.aspx 并点击我的打印按钮(不是浏览器的一个)。

  2. 打印按钮加载的内容打印的.aspx ,并显示一个打印对话框,使其在用户仍然在 View.aspx

  1. User is on "View.aspx" and clicks my Print button (not the browser's one).
  2. The Print button loads the content of "Printable.aspx" and displays a print dialog for it while the user is still on "View.aspx".

仅供参考,正是我想避免是有 Printable.aspx 在新窗口中打开,然后显示其打印对话框。

FYI, what I'm trying to avoid is to have the "Printable.aspx" open in a new window and then show its print dialog.

先谢谢了。

推荐答案

使用媒体标记的组合,CSS显示/隐藏对象。印刷

Use a combination of MEDIA tags in CSS to show/hide objects for printing.

<STYLE type="text/css">
@media print {
   .PrintOnly {font-size: 10pt; line-height: 120%; background: white;}
}
@media screen {
   .PrintOnly {display: none}
}
</STYLE>

您可以做出对自己风格的控件显示:无媒体屏幕,所以打印时,用户只能看到他们

You can make controls that are style Display:none on media screen, so the user only sees them when printing.

<DIV class="PrintOnly">
This control will only show up during printing
</DIV>



您的任何控件可以被归类为PrintOnly所以你只看到他们在打印时。你只需要拥有@media屏和一次@media打印,以确保他们的行为定义不同,一旦CSS类。

Any of your controls can be classed as "PrintOnly" so you only see them when printing. You just need to have the css class defined once for "@media screen" and once for "@media print" to ensure they behave differently.

您也可以带来。只打印整个样式表

You can also bring in an entire stylesheet for print-only.

<LINK rel="stylesheet" type"text/css" href="screen.css" media="screen">
<LINK rel="stylesheet" type"text/css" href="print.css" media="print">

这篇关于打印页面不显示呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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