Automating Print To PDF From PrintDocument In .NET

做~自己de王妃 提交于 2019-12-13 07:39:21

问题


I'd like to export a VB .NET PrintDocument to a PDF automatically (i.e. without the need for any user interaction). I've been trying to find a free PDF SDK (or something similar) that will allow me to do this. I've tried a couple of free PDF printers (Bullzip and CutePDF), both of which bring up a save dialog when the document is printed. I'd like to be able to specify the name of the PDF and save location via code, but I don't think that can be done with either of those printers.

It would be good to hear what people facing the same issue have done in the past, paid-for options included. Thanks.


回答1:


You can install BullZip and use the configuration tool to suppress all dialogs and generate the Pdf to a predefined file (same path for all print requests).

In your code, before printing, update the PDF printer configuration file by changing the output filename in the BullZip settings. Update the PDF printer configuration file C:\Users\user_name\AppData\Roaming\PDF Writer\Bullzip PDF Printer\settings.ini (one may expect variations on the directory path).




回答2:


I had similar issues to print pdf automatically through c# web application hosted in IIS. I too have provided the solution in stackoverflow you can refer that. I'm it will help you.

How to print to network printer through application hosted in IIS

Note: In case of Web Application or Window Service, You must have to do the impersonation if the app doesn't runs under a user who has the privilege to access the printer.



来源:https://stackoverflow.com/questions/30915475/automating-print-to-pdf-from-printdocument-in-net

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