Delphi:如何打印PDF而不显示? [英] Delphi: How to print a PDF without showing it?

查看:287
本文介绍了Delphi:如何打印PDF而不显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在网上看了一段时间,但是我仍然没有想到如何在Delphi中打印PDF文件,而不显示文档本身或打印对话框。我只想打开一个文件而不显示它,并将其打印到默认打印机。



我正在打印一批PDF文档,不需要用户干扰。

解决方案

打印PDF有一些不同的可能性...这取决于是否需要安装Adobe Reader不知道您是要分发您的工具还是自己使用它们。)



1)可以加载Adobe Reader的ActiveX控件并将其用于打印

  pdfFile.src:='filename.pdf'; 
pdfFile.LoadFile('filename.pdf');
pdfFile.print;

2)您可以使用Adobe Reader自己打印PDF(也可以用FoxIt打印)

  ShellExecute(0,'open','acrord32',PChar('/ p / h'+ FileName),nil,SW_HIDE) 

3)您还可以使用Ghostview和Ghostprint



ShellExecute(Handle,'open','gsprint.exe',PChar('''+ filename +'''),'',SW_HIDE);

 

4)或者你可以使用第三方库...有一些可用但不是全部他们是免费的




I have been looking online for some time now, but I still haven't figured out how to print a PDF file in Delphi without showing the document itself, or a print dialog. I just want to open a file without showing it, and print it to the default printer.

I'm trying to print a batch of PDF documents, and there is no need for user interference.

解决方案

There are some different possibilities to print PDFs... it depends whether you can require Adobe Reader to be installed (I don't know if you want to distribute your tool or just use it yourself).

1) It is possible to load the ActiveX control of Adobe Reader and use it for printing

pdfFile.src := 'filename.pdf'; 
pdfFile.LoadFile('filename.pdf'); 
pdfFile.print;

2) You can print PDFs with Adobe Reader itself (could be done with FoxIt too)

ShellExecute(0, 'open', 'acrord32', PChar('/p /h ' + FileName), nil, SW_HIDE);

3) You could also use Ghostview and Ghostprint

ShellExecute(Handle, 'open', 'gsprint.exe', PChar('"' + filename + '"'), '', SW_HIDE);

4) Or you could use a third party library... There are some available, but not all of them are free

这篇关于Delphi:如何打印PDF而不显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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