PDF-Print from C#-Program with Ghostscript on specific tray

前提是你 提交于 2019-12-04 12:39:16

Just an idea for which I'm sure it will work:

Since you are using Ghostscript, you can rasterize your PDF's to images and then print images by using PrintDocument class already built in the .NET framework. This way you can choose which tray to use by setting PageSettings.PaperSource to a different tray. Take a look at this example: How to select different tray for PrintDocument with C#

For simpler Ghostscript usage from you C# code, you can use Ghostscript.NET, a managed wrapper for the Ghostscript library. Take a look at this sample on how to rasterize PDF to image: GhostscriptRasterizer Sample.

Ghostscript.NET is also available via NuGet: http://www.nuget.org/packages/Ghostscript.NET/

If you want to do everything by using Ghostscript, you could convert your PDF's to Postscript, parse that Postscript files, modify them by adding tray select code and then print Postscript files.

Basically, no. The mswinprs2 device doesn't support any significant amount of configuration, beyond the media size and colour depth. You can have the device put up a print dialog to allow you to change the settings interactively.

Alternatively you could add it, you'd need to add a switch to specify which paper tray you want, and then alter the DEVMODE structure before the createDC creates the device context.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!