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

QPdfWriter renders gradients in a way which is rejected by macOS Preview and reports errors in Adobe illustrator

    XMLWordPrintable

Details

    Description

      When a very simple shape with basic linear gradient is rendered to a PDF file with QPdfWriter-based QPainter, resulting file is not rendered by macOS standard Preview app. When opened in the latest Adobe Illustrator, it reports "An unknown shading type was encountered.", but then opens the file correctly.

      Here's the code.

       
         QPdfWriter pdf("qtbug106790.pdf");
      
          pdf.setResolution(72);
          pdf.setPageMargins(QMarginsF(10, 10, 10, 10));
          pdf.setPageSize(QPageSize(QSize(1000, 1000)));
      
          QPainter painter(&pdf);
      
          QLinearGradient grad(0, 0, 0, 1000);
          grad.setColorAt(0, Qt::white);
          grad.setColorAt(1, Qt::black);
      
          painter.fillRect(100, 100, 800, 800, grad);
      

      The file can be opened correctly with other tools such as Adobe Acrobat Reader or Chrome

      Sample project attached ( qtbug106790.zip )

      Attachments

        1. preview.png
          preview.png
          130 kB
        2. qtbug106790.zip
          2 kB

        Issue Links

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

          Activity

            People

              vgt Eirik Aavitsland
              nagrohn Nahomi Gröhn (Inactive)
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes