[Qt-interest] pdf printer 1200 DPI and font size

Sylvain Pointeau sylvain.pointeau at gmail.com
Mon Apr 4 10:32:12 CEST 2011


Sorry for not having been clear,
I was definitely sleeping in front of my computer when I wrote the email.

I am now making a proof of concept to make a large document in PDF.
it is mainly tables and pictures but the position follows some complexes
rules,
the dimensions has to be exact.

it has to be A4 with high precision for professional printers.

I set up the printer like:

    QPrinter printer(QPrinter::HighResolution);

    printer.setOutputFormat(QPrinter::PdfFormat);

    printer.setPaperSize(QPrinter::A4);

    printer.setOutputFileName("../../../output.pdf");



But I would like to work in millimeters so I setup the painter like:

    QPainter painter;

     if (! painter.begin(&printer)) { // failed to open file

     qWarning("failed to open file, is it writable?");

     return 1;

    }

     int LogicalWidth  = 210;

    int LogicalHeight = 297;

    painter.setWindow(0, 0,LogicalWidth, LogicalHeight);


so I can draw a rectangle with millimeters by writing:

    QPen pen;

    pen.setWidthF(0.3);

    pen.setStyle(Qt::SolidLine);

    painter.setPen(pen);

     painter.drawRect( QRectF(20,20,100,50) );


here I draw a rectangle of 100 mm x 50 mm,
but when I check the pdf, as well as the printed sheet, the rectangle is
92mm x 47mm.
Is there anybody who knows why?

additionally, I have an issue with the font size, where I don't know how to
setup a font of height XX millimeters.
when I make :

    QFont myfont("Arial");

    myfont.setPixelSize(20); // it seems 20 mm but not sure, doesn't seem exact.


if I use  setPointSizeF(?);

I don't know which units it takes but it doesn't seem correct at all
(too big so far)

How should I write the number for setPointSizeF for having XX
millimeters in the PDF?


To summarize, I have 2 questions:
1. when I draw a rectangle of 100x50 mm, I have 92x47 in the PDF. Why?
2. How to setup the font size in millimeters?

Best regards,
Sylvain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110404/3a231008/attachment.html 


More information about the Qt-interest-old mailing list