如何以编程方式将 DataReport 打印到 pdf 文件? [英] How can I programatically print a DataReport to a pdf file?

查看:62
本文介绍了如何以编程方式将 DataReport 打印到 pdf 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在更新旧的 VB6 代码以将其数据报告保存为 PDF,而不是打开打印对话框.

I'm updating old VB6 code to save its DataReports out to a PDF, rather than bringing up a print dialog.

我不能简单地在代码中编写 PDF(使用 VB6 PDF 库等),因为我们所有的软件都已经使用了 DataReports,并且为每个编写打印代码充其量只是乏味的.目前,该流程需要员工将 DataReport 打印到 PDF 打印驱动程序,手动命名并将其保存到需要去的地方.我需要将这一切自动化,以便可以通过编程方式指定保存的 PDF 的名称和位置,而不是手动输入.

I cannot simply write the PDF within the code (using a VB6 PDF library, etc.), since all our software already uses DataReports, and writing print code for each one would be tedious, at best. Currently, the process requires an employee to print the DataReport to a PDF print driver, naming it manually and saving it to where it needs to go. I need to automate this all, so that the name and location of the saved PDF can be specified programatically, rather than entered by hand.

最好的解决方案是如果 DataReport 只是有一个 .SaveToPdf(filename) 例程.在最坏的情况下,我看到自己使用 SendKeys 自动执行该过程.但是,此解决方案需要在具有多个可能的打印机(因此 PDF 打印驱动程序可能不是默认设置)和 Windows XP、Vista 或 7 的环境中工作.

The best solution would be if DataReport simply had a .SaveToPdf(filename) routine. Worst-case scenario, I see myself automating the process using SendKeys. However, this solution needs to work in an environment with multiple possible printers (so the PDF print driver might not be the default,) and on Windows XP, Vista, or 7.

我尝试谷歌搜索这个问题毫无结果,它只返回有关如何手动完成的教程,就像我们现在所做的一样.

I've fruitlessly tried Googling the problem, which returns only tutorials on how to do it by hand, much as we do now.

推荐答案

您可以考虑使用 PDF 打印机驱动程序,该驱动程序允许您使用自动生成的名称将静默打印"配置到预设目录.

You might consider using a PDF Printer Driver that allows you to configure silent "printing" to a preset directory using auto-generated names.

有关此类产品的示例,请参阅:

For an example of such a product, see:

http://www.iteksoft.com/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=21

这篇关于如何以编程方式将 DataReport 打印到 pdf 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆