PDA

View Full Version : Print PDF file without using QPrintDialog



bryan.gv
27th May 2012, 05:38
Hi! ^^ I'm trying to print a PDF file without using QPrintDialog, I tried something like this:



QPrinter printer;
printer.setPrinterName("<printer's name>");

QTextDocument document;
document.setHtml("<h2>something</h2>");

document.print(&printer);



This works fine with a HTML file but I need to use a PDF file. I was looking for a way to wrap a PDF in a QDocument class or something similar but I haven't been successful :(

Thanks for your help!!!!! :)

ChrisW67
27th May 2012, 05:58
There is functionality in Qt for rendering to create a PDF file (via QPrinter). This has no direct relationship to QPrintDialog.

There is no functionality in Qt for rendering an existing PDF document to a printer. You need a third-party library to do this. For GPL programs Poppler (http://poppler.freedesktop.org/) is a popular choice, and of course, you can pay Glyph and Cog, Adobe or another commercial group to use their wares.