Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-34700

Custom paper size doesn't work with native format PDF output on Mac

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.2.1
    • 4.8.5, 5.1.1, 5.2.0 Beta1
    • GUI: Printing
    • None
    • OS X 10.8.3
    • macOS
    • 26a0a3ed85008c3a0edae125fca48c7c36a7437f

      Build and run the following code on Mac. Open the resulting PDF file. Note that the paper is still in the default letter or A4 size even though it reports the custom size is set.

      Change the output format to PdfFormat and it will be in correct size. But all text are converted to outline.

      #include <QtGui>
      #if QT_VERSION >= 0x050000
      #include <QtPrintSupport>
      #endif
      #include <QDebug>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QPrinter p;
          p.setOutputFileName("/tmp/test.pdf");
      #if defined(Q_OS_MAC)
          p.setOutputFormat(QPrinter::NativeFormat);
      #endif
          p.setPaperSize(QSizeF(5, 5), QPrinter::Inch);
          p.setMargins({0,0,0,0});
          qDebug() << p.printerName() << p.paperSize() << p.paperSize(QPrinter::Inch) << p.paperRect() << p.pageRect();
          QPainter pp(&p);
          pp.drawRect(p.pageRect());
      
          return 0;//a.exec();
      }
      
      

        For Gerrit Dashboard: QTBUG-34700
        # Subject Branch Project Status CR V

            andysh Andy Shaw
            stephenju Stephen Chu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes