无法在DocumentProperties中指定自定义纸张尺寸 [英] Unable to specify custom paper size in DocumentProperties

查看:153
本文介绍了无法在DocumentProperties中指定自定义纸张尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序允许用户指定自己的纸张尺寸和其他打印机属性,并为其设计报告.对于打印机驱动程序内置的纸张尺寸以及方向,纸张来源和双面打印选项(使用 DocumentProperties()技术在http://support.microsoft.com/kb/167345/en-us中进行了介绍.但是对于未显示在驱动程序支持的尺寸列表中的纸张尺寸(基于使用 DeviceCapabilities()以及DC_PAPERS和DC_PAPERSIZE),我的成就有限.

My application allows users to specify their own paper sizes and other printer attributes and design reports for them.  It all works well for paper sizes built-in to the printer driver, and for orientation, paper source and duplex options (using the DocumentProperties() technique described in http://support.microsoft.com/kb/167345/en-us ).  But for paper sizes which do not appear in the list of sizes supported by the driver (based on querying it with DeviceCapabilities() and DC_PAPERS and DC_PAPERSIZE), I've had only limited success. 

某些驱动程序,例如HP9000 Laserjet,允许用户定义一个自定义表格,然后显示在由其返回的支持的纸张尺寸列表中 DeviceCapabilities().但是大多数驱动程序,例如Br​​other HL-5250DN Laser,似乎都不支持此方法.但是,常见的 设备和打印机>打印服务器属性界面允许用户创建自定义表单",并且看起来应用程序应该能够使用 DEVMODE的 dmFormName 字段,直接类似于通过 dmPaperSize 字段.实际上,此方法似乎是可取的,因为它在驱动程序之间是更标准的.

Some drivers, like the HP9000 Laserjet, allow the user to define a custom form which then shows up in the list of supported paper sizes returned by DeviceCapabilities() .  But most drivers, for example the Brother HL-5250DN Laser, do not seem to support this method.  However, the common Devices and Printers > Print Server Properties interface allows users to create custom "forms", and it appears that an application should be able to then select a previously defined form using the dmFormName field of the DEVMODE, directly analogous to selecting the paper size via the dmPaperSize field.  In fact, this method seems preferable, since it is more standard across drivers. 

但是,当我使用对话框创建自定义表单时,尽管该对话框显示在 EnumForms()列表(以及与预定义纸张大小等效的大约200个内置表单"),并且在 dmFields 字段(从最初的 DocumentProperties()返回,表明驱动程序支持它),并且当我设置 dmFormName 字段,并使用 DocumentProperties()更新驱动程序(与我对其他打印机属性所做的完全一样),驱动程序似乎忽略了该设置. 例如, GetDeviceCaps(hdc,PHYSICALWIDTH)返回先前建立的纸张宽度,而不是自定义表单的宽度.

However, when I use the dialog to create a custom form, although it shows up in the EnumForms() list (along with about 200 built-in "forms" equivalent to the predefined paper sizes), and the DM_FORMNAME bit is set in the dmFields field (returned from the initial DocumentProperties() indicating that the driver supports it), and no error is returned when I set the dmFormName field and use DocumentProperties() to update the driver (exactly as I do for other printer attributes), the driver appears to ignore the setting.  GetDeviceCaps(hdc,PHYSICALWIDTH) , for example, returns the previously established paper width, rather than the width of the custom form.

我无法确定这是API中的错误,应用程序中的错误还是过程中的误解.该文档似乎尚不清楚 dmFormName 应自行设置,或与特定的设置一起设置 dmPaperSize 值,例如0或256,但是我尝试了所有排列,但结果没有任何差异.

I can't tell whether this is a bug in the API, a bug in my app, or a misunderstanding in the procedure. The documentation seems unclear on whether the dmFormName should be set by itself, or in conjunction with a particular dmPaperSize value, such as 0 or 256, but I've tried all the permutations without any difference in results.

扫描论坛,我发现了几篇有关设置自定义表单的文章,但是它们都有些陈旧(主要是谈论NT 4.0和Windows 95之间的差异),因此尚不清楚有多少文章适用仍然.另外,他们倾向于提到 使用 SetPrinter()来为其他用户/程序建立打印机设置,而我只想为一项打印作业更改它们.所以我没有用 SetPrinter().也许这是必要的吗?还是在设置时需要其他技巧 dmFormName 与其他打印机属性(例如 设置了 dmOrientation dmPaperSize ?

Scanning the forums I've found a couple of articles about setting custom forms, but they are all kind of old (mostly talking about differences between NT 4.0 and Windows 95), so it isn't clear how much of that applies still.  Also, they tend to mention using SetPrinter() in order to establish printer settings for other users/programs, whereas I only want to change them for the one print job.  So I am not using SetPrinter() .  Perhaps this is necessary? Or is there some other trick required when setting dmFormName that is different from the way other printer attributes, such as dmOrientation or dmPaperSize , are set?

我还考虑过设置 dmPaperWidth (DM_PAPERWIDTH)和 dmPaperLength (DM_PAPERLENGTH)字段,但是到目前为止,我发现支持该功能的唯一打印机驱动程序是PDF writer,因此对于必须运行的应用程序来说,这似乎不是一个好方法在各种各样的打印机上.

I've also considered setting the dmPaperWidth (DM_PAPERWIDTH) and dmPaperLength (DM_PAPERLENGTH) fields directly, but so far the only printer driver I've found that supports that feature is a PDF writer, so that doesn't seem like a good approach for an app that must work on a wide variety of printers.

也许是否存在可以与打印预览或其他非物理输出设备一起使用的标准化虚拟打印机驱动程序,以测试应用程序是否正确连接?

Is there perhaps a standardized virtual printer driver that can be used with a print preview or other non-physical output device to test whether an application is interfacing properly?   Any suggestions appreciated!

推荐答案

嗨华金,

谢谢您的问题.

Thank you for your question.

我是试图让熟悉此主题的人进一步研究此问题.可能会有一些时间延迟.感谢您的耐心.

谢谢为您的理解和支持.

Yi


这篇关于无法在DocumentProperties中指定自定义纸张尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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