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

PdfMultiPageView:: scaleToWidth compute wrong renderScale

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4.0
    • PDF
    • None
    • Windows

    Description

      Please check the following code, the scaleToWidth gives wrong renderScale.

       

      
      import QtQuick
      import QtQuick.Controls
      import QtQuick.Pdf
      
      Page {
          id: root
      
          property url source: Qt.resolvedUrl("<file:///PATH/TO/LOCAL/PDF/FILE>")
      
          function fitWidth() {
              print("view width:", view.width, ", height:", view.height);
              print("doc width:", doc.maxPageWidth, ", height:", doc.maxPageHeight);
              //view.scaleToWidth(view.width, view.height);
              view.renderScale = view.width / doc.maxPageWidth;
              print("renderScale:", view.renderScale);
          }
      
          width: 1000
          height: 600
      
          PdfDocument {
              id: doc
      
              source: root.source
              onStatusChanged: {
                  if (status === PdfDocument.Error)
                      print("failed to open pdf file:", root.source);
      
                  if (status === PdfDocument.Ready)
                      print("loading pdf file:", root.source, "success");
      
              }
          }
      
          PdfMultiPageView {
              id: view
      
              anchors.fill: parent
              document: doc
              clip: true
              onWidthChanged: {
                  root.fitWidth();
              }
          }
      
          Component.onCompleted: {
              root.fitWidth();
          }
      }
      

      Attachments

        Activity

          People

            srutledg Shawn Rutledge
            robbie_li Xiaowei Li
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: