直接使用Qt进行硬件打印,而无需使用QPrintDialog [英] Hardware Print directly using Qt without using QPrintDialog

查看:178
本文介绍了直接使用Qt进行硬件打印,而无需使用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屋!

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