如何直接在c#中打印文档

时间:2015-04-30 11:08:31

标签: c# winforms

我使用下面的代码直接在C#winform中打印文档

string fileName = @"D:\filename11" + ext; //  Here ext is file extension
PrintDocument printDoc = new PrintDocument();
printDoc.DocumentName = fileName;
printDoc.Print(); 

此代码不起作用,打印空白页。请帮忙

1 个答案:

答案 0 :(得分:3)

来自the documentation

  

DocumentName属性未指定要打印的文件。而是通过处理PrintPage事件指定要打印的输出。有关示例,请参阅the PrintDocument class overview