直接使用Qt进行硬件打印,而无需使用QPrintDialog [英] Hardware Print directly using Qt without using QPrintDialog
问题描述
我需要在单击按钮时以硬件方式打印pdf文件(已经存在的文件).
I need to hardware-print a pdf file (already existing file) on a button click.
这就像打印所需的文件已被识别并存在,并且单击打印按钮QPushButton
时,应将此pdf文件发送到打印机队列,而不会弹出用于prinitng的对话框.
It's like the file needed to print is already identified and present and upon clicking print button QPushButton
this pdf file should be sent to printer queue without popping up a dialog for prinitng.
QPrinter或Qt中的任何其他设施是否可能? (平台是linux.)
Is this possible with QPrinter or any other facility in Qt? (Platform is linux.)
推荐答案
通常,Qt(据我所知)没有内置的方法来执行此操作.您需要一个了解如何将PDF内容转换为(例如)后脚本以发送到打印机的程序.
In general, Qt has (as far as I know) no built-in way to do this. You need a program that understands how to convert PDF content into (for example) post-script to send to a printer.
Google进行了快速搜索,找到了一个名为" Poppler "的库,该库可以将PDF内容呈现到,QImage
实例,然后可以打印这些实例.
A quick Google search came up with a library called "Poppler" that can render PDF content onto, say, QImage
instances, and then you could print those.
也就是说,如果您限制自己使用linux,则可以创建一个QProcess
并调用以下内容:
That said, if you are restricting yourself to linux, you could just create a QProcess
and call something like:
lp document.pdf
这篇关于直接使用Qt进行硬件打印,而无需使用QPrintDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!