Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用.Net打印文件_C#_.net - Fatal编程技术网

C# 使用.Net打印文件

C# 使用.Net打印文件,c#,.net,C#,.net,我正在尝试使用以下代码通过.NET打印 打印机对话框窗口打开,打印作业在队列中,但是没有打印任何内容。。。我可以用其他方式打印。请参见此处的print()扩展方法: OpenFileDialog ofd = new OpenFileDialog(); if( DialogResult.OK == ofd.ShowDialog(this) ) { // Allow the user to select a printer. PrintDialog pd = new PrintD

我正在尝试使用以下代码通过.NET打印

打印机对话框窗口打开,打印作业在队列中,但是没有打印任何内容。。。我可以用其他方式打印。

请参见此处的
print()
扩展方法:

OpenFileDialog ofd = new OpenFileDialog();
if( DialogResult.OK == ofd.ShowDialog(this) )
{
    // Allow the user to select a printer.
    PrintDialog pd  = new PrintDialog();
    pd.PrinterSettings = new PrinterSettings();
    if( DialogResult.OK == pd.ShowDialog(this) )
    {
        // Print the file to the printer.
        RawPrinterHelper.SendFileToPrinter(pd.PrinterSettings.PrinterName, ofd.FileName);
    }
}