请问为什么我这样打印出来的内容是空的,一个字母都没有

jonsonzxw jonsonzxw 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的目的是将数据库中文章内容读到流中,然后输出打印,可打迎的结果是空的.


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();//开始打印
}

}

这跟内存流的编码什么的有关吗?
...全文
评论 26
收藏 已收藏
分享
返回顶部
jonsonzxw
C# 111,129 成员 642,538 内容