[PyQt] QtWebKit to PDF rendering
Sundance
sundance at ierne.eu.org
Wed Sep 23 19:21:31 BST 2009
Dominic Jacobssen wrote:
> Anyway, I've attached my efforts, and I'd greatly appreciate any
> guidance or prodding in the right direction.
Hi Dominic, hi all,
Attached herein is a version that works by sizing the PDF page
correctly. (Also the URL and destination file are command line
arguments, and no longer hardcoded, for simplicity.)
So it's still a one page PDF, but it doesn't cut off the contents
anymore.
Otherwise I couldn't find hooks for automated pagination. It may be you
will have to write those yourself, which shouldn't be horribly
complicated. Basically, I think: create a QRegion the size of your PDF
page; render the main Web frame *clipped to that region* onto the
QPrinter; issue a QPrinter.newPage(); move the region around; loop until
you've covered the whole content area.
... Also, might be a stupid question, but what happens if you use
QWebFrame.print() instead of .render()?
HTH,
-- S.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: web2pdf.py
Type: text/x-python
Size: 2015 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090923/3c6a4ee9/web2pdf.py
More information about the PyQt
mailing list