Programmatically Print to PDF

筅森魡賤 提交于 2019-12-13 22:12:51

问题


I have a customer who wants to print to PDF and Physical printer at the same time. They don't want to print the physical copy from the PDF, why I don't know. I tried saving as a temporary RTF file and calling ShellExecute to print to Adobe but doesn't appear this works.

Does anyone have a way without a 3rd party PDF library to print to PDF from a file?

UPDATE: To clarify a bit the user is working with a dynamic document creator. They see preview text on the screen in a TRichEdit and the current print method is the TRichEdit's print command (RichEdit.Print). The first attempt to a pdf was by saving the contents of this rich edit to a temp.rtf file.


回答1:


You can use our Open Source SynPdf library to export a RichEdit content into a pdf file.

See this forum post for some sample code.

It won't require any printer to be installed. And it will allow easy print preview, custom footer & header, additional title or text, if needed.




回答2:


I have used PDFForge in the past. It installs a virtual printer, and printing into this printer creates a PDF. However, it also has options to also immediately print to a physical printer, hence you will be producing a PDF and physicall copy simultaneously. See documentation here if it help you:

http://www.pdfforge.org/content/print



来源:https://stackoverflow.com/questions/12710603/programmatically-print-to-pdf

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