Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Printout cut from left on mac



  • 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(x).endsWith(".pdf")) {
                  rendered.append(render(pending.value(keys.at(x)),r.height(),r.width()));
              }
          }
          painter.begin(printer);
          for (auto x=0;x<rendered.size();++x) {
            painter.drawImage(r,rendered.at(x).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?


  • Lifetime Qt Champion

    Hi,

    You should check the bug report system.

    You might also want to add the macOS and Qt version you are currently using.



  • Hi everyone, I still have not found solution to this problem. Should this be considered a bug in Qt, a bug in my code, something absolutely else I am not aware of?


  • Lifetime Qt Champion

    Hi,

    You should check the bug report system.

    You might also want to add the macOS and Qt version you are currently using.



  • Thank you @SGaist , filed a bug report.