开发者

C# PrintDialog.PrinterSettings.CanDuplex Reports Wrongly

I'm trying to setup some code to print to different trays on a photo copier depending on what the document is (different sizes, paper colours...). It is one particular type of copier so I am not too worried about the code working in other scenarios. I still want to show the print dialog, just with the settings having better defaults for each document.

I have managed to setup the majority of what I want using properties in

PrintDialog.PrinterSettings.

However on trying to set the duplexing using

PrintDialog.PrinterSettings.Duplex = System.Drawing.Printing.Duplex.Vertical;

It fails, remaining the same as it was before. If I check if duplex is supported using

PrintDialog.PrinterSettings.CanDuplex;

It returns false which is not the case I can change it on the dialog and it prints f开发者_如何学Cine. Has anyone else had this problem? Is there a work around? Perhaps something involving COM (please be gentle not used interop code much)

It's a Gestetner 2212 copier and I believe the print server is a Windows Server 2008 machine.

Edit:

I found this link

http://bytes.com/topic/c-sharp/answers/238860-using-setprinter-c-set-duplex-option-print-prefs

Which seems to be a similar problem it seems to be some kind of problem related to using a networked printer and trying to set duplex. However the link doesn't post the solution it was emailed to them (I hate it when people do that). Anyone know how I can set the duplexing using COM interop code.


Seems network printers duplex property cannot be set in .NET code easily, even when it says it has changed the property it doesn't output correctly. There is a way to do it using com interop but it still requires modifying security levels for the printer so is more hassle than it is worth.


Try implementing a handler for the PrintPage event with following code:

if (e.PageSettings.PrinterSettings.IsValid && e.PageSettings.PrinterSettings.CanDuplex)
    e.PageSettings.PrinterSettings.Duplex = System.Drawing.Printing.Duplex.Vertical;

Tried it with a HP Laserjet M3035. It didn't show in the PrintDialog window but printed the document in duplex anyway.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜