C# 打印文档忽略打印机和纸盘设置
我有一个windows服务,它可以在收到请求后打印pdf文件。它使用PrintDocument,但对于某些打印机,它似乎忽略了我在代码中给出的打印机和纸盘设置 目前,每台打印机都有几个托盘,这些托盘都作为单独的队列安装。对于某些打印机,我只需将PrintDocument的PrinterName属性设置为队列的名称,就可以了。然而,一些印刷商似乎忽视了这一点。我也尝试设置papersource,但这似乎总是被忽略 以下是用于打印的代码:C# 打印文档忽略打印机和纸盘设置,c#,printdocument,C#,Printdocument,我有一个windows服务,它可以在收到请求后打印pdf文件。它使用PrintDocument,但对于某些打印机,它似乎忽略了我在代码中给出的打印机和纸盘设置 目前,每台打印机都有几个托盘,这些托盘都作为单独的队列安装。对于某些打印机,我只需将PrintDocument的PrinterName属性设置为队列的名称,就可以了。然而,一些印刷商似乎忽视了这一点。我也尝试设置papersource,但这似乎总是被忽略 以下是用于打印的代码: PrintDocument pd = new PrintDo
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = printer; //printer is send to the service along with the request
pd.Print();
同样:这适用于某些打印机,但不适用于所有打印机
我还尝试使用Papersource,如下所示:
pd.PrinterSettings.DefaultPageSettings.PaperSource.SourceName =
pd.PrinterSettings.PaperSources[tray - 1].SourceName; //Tray is also send with the request
pd.PrinterSettings.DefaultPageSettings.PaperSource =
pd.PrinterSettings.PaperSources[tray - 1];
就像这样:
pd.PrinterSettings.DefaultPageSettings.PaperSource.SourceName =
pd.PrinterSettings.PaperSources[tray - 1].SourceName; //Tray is also send with the request
pd.PrinterSettings.DefaultPageSettings.PaperSource =
pd.PrinterSettings.PaperSources[tray - 1];
我做错了什么
编辑:pdf文件中始终包含内容,因此不能为空。我将代码改为使用PrintQueue。这似乎很好,因为我可以直接调用队列而不是打印机。您是否尝试打印非空页面?我正在打印不能为空的pdf文件,如果是,它们永远不会到达服务。所以文件中总是有内容。对不起,我应该在问题中说明这一点。