从 C# 修改打印机默认设置
这是我的情况:
- 我正在为第 3 方程序开发 C# 插件
- 该程序 (Revit) 使用自己的打印方法并通过其 API 公开它们
- 我正在编写一个打印实用程序,它使用这些方法打印到不同的位置,包括 PDF 打印机
- 我使用 PDF995 作为打印机并修改其 .ini 文件以使其自动化。
- 基本上,我调用 API 中的 print 方法,将活动绘图打印到指定的打印机。
我的问题是,在 PDF995 上,如果您转到 Windows 中的打印首选项,则方向默认设置为“纵向”。 我需要风景。 这些设置似乎会覆盖我在 Revit API 中设置的任何内容,因此我需要一种更改 Windows 设置的方法。
我已经尝试过这段代码:
PrintDocument printDocument = new PrintDocument();
printDocument.PrinterSettings.PrinterName = "PDF995";
printDocument.DefaultPageSettings.Landscape = true;
在API中调用打印函数之前,但这没有什么区别。 我也看不到编辑 pdf995 ini 来设置这些设置的方法。 这是我需要覆盖的 Windows 设置。
我在网上看到了一些 C++ 代码,我可以调用这些代码来对打印机执行操作,但找不到更改默认设置的示例。
有人能指出我正确的方向吗?
Here's my situation:
- I'm developing a C# add-in for a 3rd party program
- This program (Revit) uses its own printing methods and exposes them through its API
- I am writing a printing utility that uses these methods to print to various locations, including a PDF printer
- I'm using PDF995 as a printer and modifying its .ini file to automate it.
- Basically I'm calling the print method in the API which prints the active drawing to a specified printer.
My problem is that on PDF995, if you go to printing preferences in Windows the orientation is by default set to 'portrait'. I need landscape. These settings seem to override anything I set in the Revit API, so I need a way of changing the windows settings.
I've tried this code:
PrintDocument printDocument = new PrintDocument();
printDocument.PrinterSettings.PrinterName = "PDF995";
printDocument.DefaultPageSettings.Landscape = true;
before calling the print function in the API, but it makes no difference. I can't see a way to edit the pdf995 ini to set these settings either. It's a windows setting that I need to override.
I've seen some C++ code on the net I can call to do things with printers but can't find an example of changing the default settings.
Can anyone point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用这些组件取得了很好的成功:
http://www.merrioncomputing.com/下载/PrintQueueWatch/index.htm
http://printqueuewatch.codeplex.com/Wiki/View.aspx?title=主页
该集合提供了各种有用的打印选项。 它主要侧重于监视打印队列,但从内存中可以使用一些选项来更改打印机设置和作业属性。
I've had good success using these components:
http://www.merrioncomputing.com/Download/PrintQueueWatch/index.htm
http://printqueuewatch.codeplex.com/Wiki/View.aspx?title=Home
This collection makes available all sorts of useful printing options. It's mainly focused on monitoring a print queue, but from memory there are options available to change printer settings and job properties.
我认为使用 Autodesk.Revit.DB.PrintManager 时的许多设置都是“占位符”,但如果打印机控制这些设置,则 Revit 移植到它的值将被忽略。 我尝试使用完整路径设置 .PrintToFileName,但在 BlueBeam 中制作 PDF 仍然会将文件发送到 MyDocuments,我必须从那里复制它。 您是否尝试过将 PDF995 复制到 PDF995X(例如)并将其修改为默认横向(而 PDF995 保留默认纵向)? 当打印机坚持使用存储的默认值而不是请求的默认值时,我过去曾使用过这种方法。
I think many of the settings from a use of Autodesk.Revit.DB.PrintManager are "placeholders", but that if the printer is controlling these settings, the value ported to it by Revit is ignored. I have tried setting .PrintToFileName with a full path, but making a PDF in BlueBeam still sends the file to MyDocuments, from where I have to copy it. Have you tried copying your PDF995 to PDF995X (for example) and modifying it to have a default of Landscape (while PDF995 retains the default of Portrait)? I have used this method in the past when a printer insists on using stored defaults instead of those requested.