打印作业期间更改打印机托盘

时间:2012-01-20 14:56:41

标签: c# .net .net-4.0 printing

有没有办法在打印作业期间切换打印机托盘?我被要求整理一个拣货/打包单程序。他们希望将库存拣货单打印在一张彩色纸上,包装在白纸上打滑,他们要妥善整理(拣货,包装,包装,包装,包装;拣货,包装,包装,包装,包装; ...)。

我在设置默认托盘时发现了一些其他线程,但在作业期间没有在交替托盘上找到任何内容。也许我不是在寻找合适的东西。

不知道它是否有所作为,但我们的打印机是HP 3015n,客户端将是XP和Win 7 Pro。

3 个答案:

答案 0 :(得分:3)

你可以尝试这样的事情,你必须从项目中引用System.Drawing.dll - >参考 - >添加

//Namespace:  System.Drawing.Printing
//Assembly:  System.Drawing (in System.Drawing.dll)

PrintDocument printDoc = new PrintDocument();
PaperSize oPS = new PaperSize();
oPS.RawKind = (int)PaperKind.A4;
PaperSource oPSource = new PaperSource();
oPSource.RawKind = (int) PaperSourceKind.Upper;

printDoc.PrinterSettings = new PrinterSettings();
printDoc.PrinterSettings.PrinterName = sPrinterName;
printDoc.DefaultPageSettings.PaperSize = oPS;
printDoc.DefaultPageSettings.PaperSource = oPSource;
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
printDoc.Print();
printDoc.Dispose();

答案 1 :(得分:0)

据我所知 - 你必须在基本上只能使用的队列中提交2个作业。

答案 2 :(得分:0)

您可以使用此代码更改打印机托盘。

string _paperSource = "TRAY 2"; // Printer Tray
string _paperName = "8x17"; // Printer paper name

//Tested code comment. The commented code was the one I tested, but when 
//I was writing the post I realized that could be done with less code.

//PaperSize pSize = new PaperSize()  //Tested code :)
//PaperSource pSource = new PaperSource(); //Tested code :)

/// Find selected paperSource and paperName.
foreach (PaperSource _pSource in printDoc.PrinterSettings.PaperSources)
{
    if (_pSource.SourceName.ToUpper() == _paperSource.ToUpper())
    {
        printDoc.DefaultPageSettings.PaperSource = _pSource;
        //pSource = _pSource; //Tested code :)
        break;
    }
}

foreach (PaperSize _pSize in printDoc.PrinterSettings.PaperSizes)
{
    if (_pSize.PaperName.ToUpper() == _paperName.ToUpper())
    {
        printDoc.DefaultPageSettings.PaperSize = _pSize;
        //pSize = _pSize; //Tested code :)
        break;
    }
}

//printDoc.DefaultPageSettings.PaperSize = pSize; //Tested code :)
//printDoc.DefaultPageSettings.PaperSource = pSource;    //Tested code :)