Delphi:如何在不显示的情况下打印 PDF? [英] Delphi: How to print a PDF without showing it?

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

问题描述

我已经在网上找了一段时间了,但我仍然没有想出如何在不显示文档本身或打印对话框的情况下在 Delphi 中打印 PDF 文件.我只想打开一个文件而不显示它,然后将其打印到默认打印机.

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.

我正在尝试打印一批PDF文档,不需要用户干预.

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

推荐答案

打印 PDF 有一些不同的可能性...这取决于您是否可以要求安装 Adob​​e Reader(不知道您是否要分发您的工具或自己使用它).

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) 可以加载 Adob​​e Reader 的 ActiveX 控件并用于打印

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) 您可以使用 Adob​​e Reader 本身打印 PDF(也可以使用 FoxIt)

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) 你也可以使用 Ghostview 和 Ghostprint

3) You could also use Ghostview and Ghostprint

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

4) 或者你可以使用第三方库...有一些可用的,但不是所有的都是免费的

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天全站免登陆