mercredi 6 juillet 2016

QPrinter margin does not work as expected

I am working on printing with Qt C++. But I found a problem that the margin does not work as expected. Here the QPrinter configuration I used. QPrinter *pr = new QPrinter(QPrinterInfo::printerInfo("Canon iP2700 series")); pr->setPageSize(QPrinter::A4); pr->setFullPage(true); pr->setPageMargins(5, 5, 5, 5, QPrinter::Millimeter); QTextDocument *d = new QTextDocument(this); d->setHtml("<i>Try printing from QT</i>"); d->print(pr); And the result margin is really far away from the edge (it should be 5mm), I also try to print it on real printer. And it seems the printer has internal margin, and the margin I set to the printer will be added to the internal margin. In my issue, the internal margin is 20mm. So if i set the printer margin to 10mm, when it printed, the margin on paper is 30mm. Is there anyone has experience about this? How the to make the margin works? PS: I am using Qt 5.5 VC 2013.

Aucun commentaire:

Enregistrer un commentaire