Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.14.2
-
None
-
macOS 10.15 with latest updates.
Description
Good afternoon,
I am struggling to identify issue with printing. It appears on mac only.
Task:
- content is rendered to the image of the specified size (taken from printer settings)
- content is written as pdf using QPdfWriter
- content is sent to printer
Code (boilerplate template really, minimum working example):
{{// "rendered" is a vector of QImage}}
{{ // "pSize" is QPageSize with a proper page size for selected printer}}
{{ // "keys" is QStringList with the document list}}
{{ // "render" is helper method that fills in the "rendered" vector as I use different backends for mac and windows}}
QPrinter *printer = new QPrinter(QPrinterInfo::printerInfo(ui->printerCombo->currentText()),QPrinter::HighResolution);
printer->setPageSize(pSize);
ui->portraitBox->isChecked() ? printer->setOrientation(QPrinter::Portrait) : printer->setOrientation(QPrinter::Landscape);
printer->setFullPage(true);
QRect r;
r = printer->pageRect(QPrinter::DevicePixel).toRect();
for (auto x=0;x<keys.size();++x) {
if (keys.at.endsWith(".pdf")) {
rendered.append(render(pending.value(keys.at),r.height(),r.width()));
}
}
painter.begin(printer);
for (auto x=0;x<rendered.size();++x) {
painter.drawImage(r,rendered.at.scaled(r.width(),r.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation));
{{ // that scale is not necessary above, it is leftover after some experiments to try to find out the solution}}
{{ if (x<rendered.size()1) { printer>newPage(); }}}
}
painter.end();
delete printer;
Problem:
On mac left side of the printout is cut slightly, about 2mm, half a width of a capital letter P.
On windows works flawlessly.
Moreover, on both platforms saving content with QPdfWriter produces perfectly valid pdf files, so rendering process works without issue.
Just the printing...
Can anyone recommend or comment on this please?