Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Printout cut from left on mac

Printout cut from left on mac

Scheduled Pinned Locked Moved Solved General and Desktop
qprintermacosxmac
4 Posts 2 Posters 580 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • artwawA Offline
    artwawA Offline
    artwaw
    wrote on last edited by
    #1

    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?

    For more information please re-read.

    Kind Regards,
    Artur

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi,

      You should check the bug report system.

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • artwawA Offline
        artwawA Offline
        artwaw
        wrote on last edited by
        #2

        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?

        For more information please re-read.

        Kind Regards,
        Artur

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #3

          Hi,

          You should check the bug report system.

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • artwawA Offline
            artwawA Offline
            artwaw
            wrote on last edited by
            #4

            Thank you @SGaist , filed a bug report.

            For more information please re-read.

            Kind Regards,
            Artur

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved