我写的打印预览窗口可以看到打印文档的内容,但是点击“print”后就是空白页了,不知道该怎么改了。
源代码如下:
private void PreviewFile_Click(object sender, System.EventArgs e)
        {
            try
            {
                string strText = this.rtxPrintText.Text;
                //从编辑器窗口中读取串
                myReader = new StringReader(strText);
                PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
                //实例化新的打印预览对话框
                printPreviewDialog1.Document = this.ThePrintDocument;
                ThePrintDocument.PrintPage += new PrintPageEventHandler(this.ThePrintDocument_PrintPage);
                //printPreviewDialog1.BorderStyle = FormBorderStyle.Fixed3D;
                printPreviewDialog1.ShowDialog();
                //使用打印页事件来重画预览窗口向用户展示打印预览对话框
            }
            catch(Exception exp)
            {
                System.Console.WriteLine(exp.Message.ToString());
            }
        }

其中的ThePrintDocument_PrintPage方法和msdn帮助上的一样