如何从aspx调用IE的打印预览 [英] how to call print preview of IE from aspx

查看:190
本文介绍了如何从aspx调用IE的打印预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,我在aspx页面上有一个打印预览"按钮,我想使用IE7、8、9的打印预览功能.
我在Google上找到了一些代码,但没有一个对我有用,我正在使用IE9.
问题是如何通过按钮调用IE的打印预览?

Dear All, I have a button "Print Preview" in my aspx page which i want to use print preview function of IE7,8,9.
I Google and i find some codes but none worked for me, i am using IE9.
the question is how can i call the print preview of IE from my button?

推荐答案

整洁的文章,如果您想使用Javascript-
Neat artcle if you want to use Javascript - Creating print preview page dynamically in ASP.NET[^]


嘿!以下代码可能会对您有所帮助.
Hey! Following code might help you out.
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)

{

           e.Graphics.DrawString(richTextBox1.Text, richTextBox1.Font, Brushes.Black, 100, 20);

           e.Graphics.PageUnit = GraphicsUnit.Inch;

}



Step2:  write code for printing and print preview.



private void btnPrint_Click(object sender, EventArgs e)

{

            //PrintDialog associate with PrintDocument;

            printDialog1.Document = printDocument1;



            if (printDialog1.ShowDialog()==DialogResult.OK)

            {

                printDocument1.Print();

            }

}



private void btnPrintPreview_Click(object sender, EventArgs e)

{

            //Associate PrintPreviewDialog with PrintDocument.

            printPreviewDialog1.Document = printDocument1;



            // Show PrintPreview Dialog

            printPreviewDialog1.ShowDialog();

}


这篇关于如何从aspx调用IE的打印预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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