是否可以使用C#更改打印机方向? [英] Is it possible to change printer orientation using C#?

查看:368
本文介绍了是否可以使用C#更改打印机方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在加载打印卡的Web浏览器控件上的html内容。在打印之前,我想将方向设置为横向或纵向取决于卡。请帮我实现这个目标



我尝试过:



我尝试更改注册表并从c#更改打印机首选项两者都不起作用。

I am loading the html content on web-browser control for printing card. Before printing i want to set the orientation as landscape or portrait depends on card. please help me to achieve this

What I have tried:

I tried to change registry and change printer preferences from c# both are not working.

推荐答案

是的,它可能,但远非易事......第一种方法我想是从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


这篇关于是否可以使用C#更改打印机方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆