QPrinter 边距不按预期工作

QPrinter margin does not work as expected

我正在使用 Qt C++ 进行打印。但是我发现了一个问题,margin 没有按预期工作。这里是我使用的 QPrinter 配置。

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);

而且结果边距真的离边缘很远(应该是5mm),我也试着用真机打印出来。而且打印机好像有内边距,我给打印机设置的边距会加到内边距上。

我这期的内边距是20mm。因此,如果我将打印机边距设置为 10mm,打印时,纸张上的边距为 30mm。

有没有人有这方面的经验?保证金如何运作?

PS: 我正在使用 Qt 5.5 VC 2013.

稍微深入阅读了文档。它说 QTextDocument 将在打印时添加 20mm 边距。

By default a 2 cm margin is set around the document contents

而且我需要在打印之前设置页面大小。