Qpdfwriter and qpainter
-
Hello at all
i have write this few line
@QPdfWriter pdf(nomefile+".pdf");
pdf.setPageSize(QPagedPaintDevice::A4);
QPainter painter(&pdf);
QFont carattere("Arial");
carattere.setPixelSize(18);
painter.setFont(carattere);
painter.drawText(700,-100,"Att.n "+customer.trimmed());@but when i print the pdf page i get a very small text located approx in the centre of the page what is wrong?
Thanks
Luca
-
Hi,
setPixelSize() and drawText() use pixel dimension;
using QFont::setPointSize() you can set font size in point (dpi independent way).
-
Hello
now the font are ok, but i have a problem with the page size and the x,y referenceif i use drawText(0,0,"my_text")
i understand that my_text is written on the upper left of my A4 page, but he write approx in the center of the page.
Also the page dimension is not A4 but is 1x1.5 in why if i set it to A4.Thanks Luca
-
I noticed the same behaviour, I think it's a QPdfWriter bug.
With QPrinter and PdfFormat all works fine -
I notice that QPdfWriter has a logical DPI of 1200. Maybe that's what messes things up?
-
Checking whether I could get rid of the need for QtPrintSupport (using QPrinter as PDF-Producer), I stumbled upon QPdfWriter.
Unfortunately, it's currently buggy and I'm a bit wondering how it made it into a release in the first place in the current shape. Texts are a common thing in PDFs, no? ;)
I have issued a bugreport, if anyone is also interested in this (otherwise very promising) class, please upvote and watch it: