打印页面而不打印对话框? [英] Printing a page without the Print dialog box?

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

问题描述

我有这个ASP.NET页面,我想打印。我在做什么,现在是使用的OnClientClick 并从那里调用一个函数 PrintThePage()这不只是做一个来电 Window.Print()。当我这样做,用户在打印对话框,在这里她可以选择打印机(并设置其属性,什么不可以),然后打印页面psented $ P $。

I have this ASP.NET page which I would like to print. What I am doing right now is using OnClientClick and from there calling a function PrintThePage() which does nothing but make a call to Window.Print(). When I do this, the user is presented with the Print dialog box, where she can select the printer (and set its properties and what not) and then print the page.

问题是我要打印的页面,而不显示打印对话框,使用默认打印机。以下是我已经试过:

The problem is I want to print the page without showing the print dialog box, using the default printer. Here's what I've tried:

protected void Page_Load(object sender, EventArgs e)
{
    System.Drawing.Printing.PrinterSettings ps =
        new System.Drawing.Printing.PrinterSettings();

    ps.PrintFileName = Path.GetFileName(Request.Url.LocalPath);

    System.Drawing.Printing.PrintDocument pd =
        new System.Drawing.Printing.PrintDocument();

    pd.PrinterSettings = ps;
    pd.Print();
}

我的默认打印机的OneNote (微软发送给一个注)。 问题:虽然页面可以打印,只有一个空白页产生

My default printer is OneNote (Microsoft send to One Note). The problem: While the page does print, only a blank page is produced.

我第一次尝试设置我的默认打印机 doPdf 。如果没有工作,然后我试图用我的真正的惠普打印机。但我仍然收到了同样的结果。该页面未显示打印对话框......这个问题已经一去不复返了。但问题是为什么是页面不打印?为什么我得到一个空/空/虚无缥缈的网页?有没有在我的code的一个问题?抑或是我的打印机的错?同样,一个问题已经一去不复返了;我不再获得打印对话框。我只是没有得到打印的页面,只是一个空白页。

I first tried to set my default printer to doPdf. When that did not work, I then attempted to use my real HP printer. But I still received the same result. The page isn't showing the print dialog box...that problem is gone. But the problem is why is the page not printing? Why I am getting a blank/null/nada page? Is there a problem in my code? Or is it the fault of my printer? Again, one problem is gone; I am no longer getting the Print Dialog Box. I'm just not getting a printed page, just a blank page.

谁能告诉我发生了什么事?我能做些什么来实现我的目标? (我希望我使自己很清楚!)。

Can anyone tell me what's happening? What can I do to achieve my goal? (I hope I have made myself clear enough!).

推荐答案

我想你混淆了客户端与打印服务器上打印。

I think you have confused client side printing with printing on the server.

您可以打印使用Java,有的优惠券打印机是如何工作的客户端。然而,这是令人难以接受的。客户应该始终有他们想要如何打印的选择。

You can print on the client side with Java, how some coupon printers work. However, this is frowned upon. The client should always have a choice of how they want it printed.

的Page_Load 的调用将在服务器端的打印机来完成。

The calls on Page_Load would be done on the server-side printers.

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

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