开发者

PrintDocument.PrinterSettings.Duplex Network Printer

开发者 https://www.devze.com 2023-03-29 23:40 出处:网络
I am trying to print my document to a specific printer, tray and set the duplex settings using code like this:

I am trying to print my document to a specific printer, tray and set the duplex settings using code like this:

void PrintingSystem_StartPrint(object sender, PrintDocumentEventArgs e)
{
    //e.g. \\patch2\MIU Copier
    e.PrintDocument.PrinterSettings.PrinterName = printerName; 
    //e.g. Tray 2
    e.PrintDocument.DefaultPageSettings.PaperSource = paperSource; 

    if (e.PrintDocument.PrinterSettings.CanDuplex)
        e.PrintDocument.PrinterSettings.Duplex = System.Drawing.Printing.Duplex.Horizontal;
}

The PrinterName and PaperSource settings work perfectly but the CanDuplex property is always false despite knowing the copier is capable of this. Also if I exclude the if statement and just set the property anyway it still prints in simplex. Is there any way to do what I want I have had a bit of a google and it seems it may be an issue specifically with network printers but I haven't found any work around.

Edit: I have since tried it on a few different network printers (copiers) and it seems to work on some and not others. Namely doesn't work on Gestetner 2212 PCL 5e but does work on Ricoh Aficio MP C2550. Looks like it may be bad drivers reporting wrongl开发者_运维百科y, I will leave the question for now for any comments.


I can imagine that setting the PrinterName property of the PrinterSettings instance that is associated with the PrintDocument does not update properties such as CanDuplex as expected.

Try creating a new PrinterSettings instance and setting the PrinterName property and then take a look at the CanDuplex property to see if the behavior is different. Next assign that PrinterSettings instance to PrintDocument.PrinterSettings.

I am just thinking out loud and did not try this...

0

精彩评论

暂无评论...
验证码 换一张
取 消