且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以使用C#更改打印机方向?

更新时间:2023-01-29 19:41:18

是的,它可能,但远非易事......第一种方法我想是从Microsoft下载Windows Server 2003资源工具包,下载Windows来自Microsoft官方下载中心的Server 2003资源工具包工具 [ ^ ],找到'SetPrinter.exe'实用程序,看看是否可以在手动意义上帮助你



如果是工作,一个选项可能是在触发页面打印之前将该exe作为具有适当参数的进程触发,但是,它是一个丑陋的解决方案



另一种选择,这是亩更难以正确,但'更好',是使用PInterop,也许这篇文章改变使用C#进行打印机设置 [ ^ ]作为起点
yes, its possible, but 'far from easy' ... the first approach I'd think about would be to download the Windows Server 2003 resource kit from Microsoft, Download Windows Server 2003 Resource Kit Tools from Official Microsoft Download Center[^], find the 'SetPrinter.exe' utility, and see if that helps you in the manual sense

If that works, one option may be to fire that exe off as a process with appropriate parameters, before you trigger the page print, but, its an ugly solution

The other option, which is much harder to get correct, but 'nicer', is to use PInterop and maybe this article Changing printer settings using C#[^] as a starting point