[Interest] Creating pdf with QTextDocument with chart

Jason H jhihn at gmx.com
Mon Oct 26 16:04:23 CET 2015


There is always a way.

Alternatives: 
1. Distribute a Qt 5.0 static (or dynamically linked) binary for printing.
2. Use QPrinter to print the report, requiring the user to have a PDF print driver installed. You can select this printer in Qt, so once set there is no need to bring up the QPrintDialog.

QPrinter will go everything you need aside from the writing of the PDF file. In fact, I can run my code against a QPrinter or QPdfWriter. The printer exists as a paged device, the pages are coordinate spaces just like a QWidget. In fact you can map things to the pave via QWidget::render()


> Sent: Monday, October 26, 2015 at 10:34 AM
> From: Duane <duane.hebert at group-upc.com>
> To: interest at qt-project.org
> Subject: Re: [Interest] Creating pdf with QTextDocument with chart
>
> On 26/10/2015 10:24 AM, Jason H wrote:
> > The basic fall-back for this is to render the chart as an image.
> >
> > I render PDFs with Qt, but I came up with my own framework. Basically, I using QPdfWriter it is possible to treat it as a widget, and have it lay itself out on the page too!
> > So what I so is I have several QWidget-derived classes that are positioned in the widget hierarchy, with spacers, properties, and constraints set just as a QWindow would, and have that go to the page. Each page is laid out this way, with QPdfWriter::newPage() called between them.
> >
> > There is a bug in QPdfWriter though, where the font size needs to be manually scaled for logical DPI when using point sizes.
> >
> >
> >> Sent: Friday, October 23, 2015 at 12:21 PM
> >> From: Duane <duane.hebert at group-upc.com>
> >> To: interest at qt-project.org
> >> Subject: [Interest] Creating pdf with QTextDocument with chart
> >>
> >> I need to create a document as a pdf file for my application.  I can use
> >> QTextDocument and html to do most of the document but I need to add a
> >> chart to it.
> >>
> >> I'm using Qt 4.8.  Any suggestions?
> >>
> >> _______________________________________________
> >> Interest mailing list
> >> Interest at qt-project.org
> >> http://lists.qt-project.org/mailman/listinfo/interest
> >>
> 
> 
> Thanks.  But unfortunately we're at Qt 4.8 and QPDFWriter is available 
> on in Qt5 as far as I can tell.  I don't see a way to generate a report 
> in pdf with Qt4 other than QTextDocument/QPrinter and in that case I 
> don't see a way to get the chart into it.
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> 



More information about the Interest mailing list