简体   繁体   English

从 Windows 服务打印 PDF

[英]Printing a PDF from a Windows service

With C#, how can I print a PDF document (without any dialog boxes in the background) to an indicated printer?使用 C#,如何将 PDF 文档(后台没有任何对话框)打印到指定的打印机?

I have used the following PDF library in the past to perform batch printing of PDF documents from a C# Windows Service.我过去曾使用以下 PDF 库从 C# Windows 服务执行批量打印 PDF 文档。

http://www.quickpdflibrary.com/ http://www.quickpdflibrary.com/

It's a pretty decent library and if I remember correctly it only took a few lines of code to print the document.这是一个相当不错的图书馆,如果我没记错的话,它只需要几行代码就可以打印文档。 It worked very well and saved me a consider amount of time.它运作良好,为我节省了大量时间。

Also, the recommended link that discusses using DDE to launch a desktop application on a server to perform the printing is a bad idea.此外,讨论使用 DDE 在服务器上启动桌面应用程序以执行打印的推荐链接是一个坏主意。 Adobe Reader probably doesn't support this and since it is a desktop application running in a windowless session you may run into problems with message boxes and dialog boxes. Adobe Reader 可能不支持这一点,因为它是一个在无窗口 session 中运行的桌面应用程序,您可能会遇到消息框和对话框的问题。 That solution just doesn't scale in my humble opinion.根据我的拙见,该解决方案无法扩展。

Disclaimer: I work for Atalasoft免责声明:我为 Atalasoft 工作

If you don't want to depend on Acrobat being on the server, you need to rasterize the PDF pages yourself and send them to the printer using the normal .NET printing API. We have a product that can rasterize PDF that uses the Foxit engine underneath.如果你不想依赖服务器上的Acrobat,你需要自己光栅化PDF页面,然后使用正常的.NET打印API将它们发送到打印机。我们有一个产品可以光栅化PDF ,它使用下面的Foxit引擎. It deploys as a normal .NET assembly and doesn't require any other software to be installed.它作为一个普通的 .NET 程序集部署,不需要安装任何其他软件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM