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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • 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

    Description

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

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes