请问为什么我这样打印出来的内容是空的,一个字母都没有
我的目的是将数据库中文章内容读到流中,然后输出打印,可打迎的结果是空的.
System.IO.MemoryStream stream = new MemoryStream();
string content = reader.GetString(2);
byte[] byteArray = Encoding.Default.GetBytes(content);
stream.Write(byteArray,0,byteArray.Length);
StartPrint(stream);
StartPrint()方法的定义如下
public void StartPrint(Stream streamToPrint)
{
this.streamToPrint=streamToPrint;
// Allow the user to choose the page range he or she would
// like to print.
printDialog1.AllowSomePages = true;
// Show the help button.
printDialog1.ShowHelp = true;
// Set the Document property to the PrintDocument for
// which the PrintPage Event has been handled. To display the
// dialog, either this property or the PrinterSettings property
// must be set
printDialog1.Document = printDocument1;//把PrintDialog的Document属性设为上面配置好的PrintDocument的实例
DialogResult result = printDialog1.ShowDialog();//调用PrintDialog的ShowDialog函数显示打印对话框
// If the result is OK then print the document.
if (result==DialogResult.OK)
{
printDocument1.Print();//开始打印
}
}
这跟内存流的编码什么的有关吗?