private void btnPrintLook_Click(object sender, EventArgs e)
{
PrintDocument document=new PrintDocument();
printLook.Document = this.printDoc;
printLook.ShowDialog();
}
这是我的代码,在打印预览时,只有空白文档,不知为什么?
还有就是怎样在打印中导入文件(用代码)及打印当前页?请教大家;
{
PrintDocument document=new PrintDocument();
printLook.Document = this.printDoc;
printLook.ShowDialog();
}
这是我的代码,在打印预览时,只有空白文档,不知为什么?
还有就是怎样在打印中导入文件(用代码)及打印当前页?请教大家;
{
PrintDocument document = new PrintDocument();
document.PrintPage += new PrintPageEventHandler(document_PrintPage);
printLook.Document = document;
printLook.ShowDialog();
} void document_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString("aaaaaaaaaaaa", new System.Drawing.Font("黑体",40), Brushes.Red, 0, 0);
}这样用的.
document上的内容是要自己填充的他的aaaaaaaaaaaa就是说在0,0的位置上用40的黑体写了一段字符串aaaaaaaaaaaa
- -
主要问题是预览框中出现的是空白的,没有aaaaaaaa或者任何字符,这是怎么回事
是wwinform么?using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;namespace CodeTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
PrintPreviewDialog printLook = new PrintPreviewDialog();
private void button1_Click(object sender, EventArgs e)
{
PrintDocument document = new PrintDocument();
document.PrintPage += new PrintPageEventHandler(document_PrintPage); printLook.Document = document;
printLook.ShowDialog();
} void document_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString("aaaaaaaaaaaa", new System.Drawing.Font("黑体", 40), Brushes.Red, 0, 0);
} }
}
整段程序你试试
不会是你类用错了吧?还是没开延迟打印服务?
- -我只是说说,以前我犯过这个错误……
用GDI+自己一个个画就行了。
正如14楼说的,是要自己画的=- =除非你原版就是用的office组件,他本身功能就能实现