以编程方式打印到pdf打印机 [英] Printing to a pdf printer programmatically

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

问题描述

我正在尝试在Visual Basic 2008中以编程方式将现有文件打印为PDF.

我们当前的相关资产为: Visual Studio 2008专业版 Adobe Acrobat Professional 8.0

我曾考虑过要获得一个像ITextSharp这样的sdk,但是对于我正在尝试做的事情来说似乎有些过头了,尤其是因为我们拥有完整版的Adobe.

是否有相对简单的代码即可打印到PDF打印机(当然,也可以将其分配给特定位置打印)?还是需要使用另一个库才能打印到pdf?


我想将以前创建的文档打印为pdf文件.在这种情况下,它是一个我想制作为.pdf文件的.snp文件,但我认为任何文件类型的逻辑都相同.


我只是尝试了上面的shell执行,它不会按照我想要的方式执行.因为它会提示我要打印的位置,但仍然不打印我要打印的位置(多个位置),这一点至关重要,因为我们创建了许多相同名称的PDF文件(PDF中包含不同的数据,并放置在相应的客户端文件夹)


当前过程是:

  • 转到\\报告服务器\ client1
  • 手动在文件夹中创建所有snp文档的pdf文件
  • 将pdf复制到\\网站报告\ client1
  • 然后对所有100多个客户重复一次,大约需要两个小时才能完成并验证

我知道可以做得更好,但我来这里只有三个月,还有其他紧迫的问题要立即解决.我也没想到看起来如此琐碎的东西很难编写.

解决方案

这里最重要的一点是PDF很难.如果有什么可以避免直接创建或编辑PDF文档的方法,强烈建议您这样做.听起来您真正想要的是批处理SNP到PDF转换器.您可能可以使用现成的产品来执行此操作,甚至根本不需要打开Visual Studio.有人提到Adobe Distiller Server-检查您的Acrobat文档,我知道它是基本的Distiller附带的,您也许可以将Distiller设置为以类似的模式运行,在该模式下,它可以监视目录A并吐出任何文件的PDF版本显示在目录B中.

另一种选择:由于您正在使用Access快照,因此最好编写一个VBA脚本,该脚本可遍历目录中的所有SNP并将它们打印到已安装的PDF打印机中.

ETA:如果需要指定PDF打印机的输出,可能会更难.我建议您将PDF分配器配置为输出到临时目录,这样您就可以打印一个,移动结果,然后打印另一个,依此类推.

I am trying to print an existing file to PDF programmatically in Visual Basic 2008.

Our current relevant assets are: Visual Studio 2008 Professional Adobe Acrobat Professional 8.0

I thought about getting a sdk like ITextSharp, but it seem like overkill for what I am trying to do especially since we have the full version of Adobe.

Is there a relatively simple bit of code to print to a PDF printer (and of course assign it to print to a specific location) or will it require a the use of another library to print to pdf?


I want to print a previosly created document to a pdf file. In this case it a .snp file that I want to make into a .pdf file, but I think the logic would be the same for any file type.


I just tried the above shell execute, and it will not perform the way I want it to. as it prompts me as to where I want to print and still does not print where I want it to (multiple locations), which is crucial as we create a lot of the same named PDF files (with different data within the PDF and placed in corresponding client folders)


The current process is:

  • Go to \\report server\client1
  • create pdf files of all the snp documents in the folder by hand
  • copy the pdf to \\website reports\client1
  • then repeat for all 100+ clients takes roughly two hours to complete and verify

I know this can be done better but I have only been here three months and there were other pressing concerns that were a lot more immediate. I also was not expecting something that looks this trivial to be that hard to code.

解决方案

The big takeaway point here is that PDF IS HARD. If there is anything you can do to avoid creating or editing PDF documents directly, I strongly advise that you do so. It sounds like what you actually want is a batch SNP to PDF converter. You can probably do this with an off-the-shelf product, without even opening Visual Studio at all. Somebody mentioned Adobe Distiller Server -- check your docs for Acrobat, I know it comes with basic Distiller, and you may be able to set up Distiller to run in a similar mode, where it watches Directory A and spits out PDF versions of any files that show up in Directory B.

An alternative: since you're working with Access snapshots, you might be better off writing a VBA script that iterates through all the SNPs in a directory and prints them to the installed PDF printer.

ETA: if you need to specify the output of the PDF printer, that might be harder. I'd suggest having the PDF distiller configured to output to a temp directory, so you can print one, move the result, then print another, and so on.

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

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