我正在使用 RawPrinterHelper 类,如下所述: https://support.microsoft.com/en-us/help/322091/how-to-send-raw-data-to-a-printer-by-using-visual- c-.net
我完全按照示例使用代码,它似乎立即工作,没有错误 - 除了它实际上没有打印。
检查打印队列显示打印作业出现,然后立即消失。如果我更改属性以保留旧打印,我可以看到它将作业分类为“已打印”。然而实际上什么也没有打印出来!
我尝试过使用记事本、Word 和 Excel 直接打印到打印机,并且全部成功。我尝试了 3 台不同的打印机,甚至在另一台机器上使用不同的打印机重新完成了工作,但仍然遇到相同的问题。
我使用的是Windows 10专业版和VS2017。
任何建议将不胜感激。
private void button1_Click(object sender, EventArgs e)
{
//Allow the user to select a file.
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);
}
}
//other tests - these both …Run Code Online (Sandbox Code Playgroud)