[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: Print preview and print PDF in PyQT5
From: Giuseppe Corbelli <corbelligiuseppe () mesdan ! it>
Date: 2020-06-16 8:52:21
Message-ID: 8a4541cb-dfc5-f965-8132-e95f83e1a406 () mesdan ! it
[Download RAW message or body]
On 6/12/20 1:08 PM, Justin Giffard wrote:
> Good afternoon
>
> I'm looking for a way to make a print preview and print a PDF. I've
> tried various things including trying to use a webview and print from
> there without much success.
>
> Currently I am generating a PDF with reportlab but ideally what I want
> is to be able view the document after the pdf is generated (based on
> data fetched from a database) and then if need be press cancel to alter
> the parameters and then view it again then chose which printer I want
> to print to and then print. Thus far I haven't had much luck other than
> making the app open the document in an external browser / external PDF
> viewer and then printing from there or blindly printing to the default
> printer.
Well these are 2 separate questions, and you're not mentioning what OSes
you want this stuff to run on.
QtWebEngine supports viewing and printing PDFs [1].
PDF preview:
* poppler [2][3]
* qpdfview (or any other) that have a DBUS interface
As for the printing stuff, if you use poppler you can render to QImage
and print that using QPrinter / QPainter.
This has some more info
https://wiki.qt.io/Handling_PDF
[1] https://doc.qt.io/qt-5/qtwebengine-features.html
[2] https://pypi.org/project/python-poppler-qt5/#description
[3] http://shallowsky.com/blog/programming/qt5-poppler-pdf.html
--
Giuseppe Corbelli
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic