[Interest] QPdfWriter - ability to embed XML?

Jason H jhihn at gmx.com
Wed Jun 10 20:20:57 CEST 2015


I have a months-open bug. It took me forever to convince the trolls that it is a bug. What I discovered is that it assumes 72dpi, rather than using the proper DPI setting. Scaling your fonts by newDPI/72 *fontSize will get it to the correct size. Note that when printing I only ever use pointSize, not pixelSize.
 
https://bugreports.qt.io/browse/QTBUG-45082
 
 
Though the bug description I think is some-what over limiting. I have it on Linux too, where it was discovered. I don't know why/if it is limited to widgets. But I wrote a trivial function to find the QLabels and such to adjust their font size before rendering. (At this point in the discussion I should mention I do my print-outs as widgets, with a widget heirarchy)


Code:
> > void PdfReport::fixFonts(QObject *w, QPaintDevice *pd) {
> > qreal ratio = pd->logicalDpiX() / 72.0;
> > fixFonts(w,ratio);
> > }
> >
> > void PdfReport::fixFonts(QObject *w, qreal ratio) {
> > foreach (QObject *c, w->children())
> > {
> > QString cname = c->metaObject()->className();
> > if (cname == "QLabel") {
> > QLabel *l = qobject_cast<QLabel*>(c);
> > if (l) {
> > QFont f = l->font();
> > f.setPointSize(f.pointSize()*ratio);
> > l->setFont(f);
> > }
> > }
> > fixFonts(c, ratio);
> > }
> > }




 

Sent: Wednesday, June 10, 2015 at 1:35 PM
From: "Edward Sutton" <edward.sutton at subsite.com>
To: "Giuseppe D'Angelo" <dangelog at gmail.com>
Cc: "interest at qt-project.org" <interest at qt-project.org>
Subject: Re: [Interest] QPdfWriter - ability to embed XML?

Hi Giuseppe, 

On Jun 10, 2015, at 11:57 AM, Giuseppe D'Angelo <dangelog at gmail.com> wrote: 
On Wed, Jun 10, 2015 at 6:51 PM, Edward Sutton
<edward.sutton at subsite.com[edward.sutton at subsite.com]> wrote:

Crap. It looks like I could have used QPdfWriter on iOS and saved me a lot
of Objective-C headaches.  I replaced QPrinter with QPdfWriter and it
basically seems to work except the fonts in the PDF are extremely tiny.  I
may have to switch to QPdfWriter now.
This looks like a bug that should have been already solved in 5.4.x.
If not, please report it!
 
I am using Qt 5.5 RC snapshot.  
 
Are you saying the *very* *small* font size is a possible bug?
 
I changed to using pointsize and now my drawn text is legible.
 
 
However all output rendered using QTextDocument::setHtml(“<h3>Hello World</h3>”) still renders *very* *very* small.
 
 
I assumed the “tiny font” issue might be the result of QPdfWriter using point size for fonts and QPrinter was using pixel size?
 
-Ed
 
--
Giuseppe D'Angelo
This email and any files transmitted with it from The Charles Machine Works, Inc. are confidential and intended solely for the use of the individual or entity to which they are addressed. If you have received this email in error please notify the sender. Our company accepts no liability for the contents of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. _______________________________________________ Interest mailing list Interest at qt-project.org http://lists.qt-project.org/mailman/listinfo/interest[http://lists.qt-project.org/mailman/listinfo/interest]



More information about the Interest mailing list