Sha*_*okh 5 c# printing .net-3.5 visual-studio-2008
可能重复:
使用C#将文档发送到打印机
我想将字符串值直接发送到打印机.当然,我可以将数据表发送到打印机.但首先我想知道如何在没有任何提示最终用户打印机的情况下发送我的字符串值.我在互联网上搜索了3个小时但没有找到回应.请帮我.谢谢 :)
Dam*_*ith 15
你可以PrintDocument在System.Drawing.Printing命名空间下使用.Print方法将使用您的默认打印机打印字符串
string s = "string to print";
PrintDocument p = new PrintDocument();
p.PrintPage += delegate(object sender1, PrintPageEventArgs e1)
{
e1.Graphics.DrawString(s, new Font("Times New Roman", 12), new SolidBrush(Color.Black), new RectangleF(0, 0, p.DefaultPageSettings.PrintableArea.Width, p.DefaultPageSettings.PrintableArea.Height));
};
try
{
p.Print();
}
catch (Exception ex)
{
throw new Exception("Exception Occured While Printing", ex);
}
Run Code Online (Sandbox Code Playgroud)
从这里找到例子
| 归档时间: |
|
| 查看次数: |
27190 次 |
| 最近记录: |