Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Error in PdfDocument documentation?

Error in PdfDocument documentation?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 391 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.
  • M Offline
    M Offline
    malocascio
    wrote on last edited by
    #1

    I'm trying to display a PDF inside my QtQuick2 application (Qt 5.15). In my googling, I found the PdfDocument QML type documentation, and in the detailed description section, it states that the PdfDocument object "is not necessary for rendering, as it is enough to use an Image with source set to the URL of the PDF."

    I interpret that to mean that I can just use a regular QML Image and point the source at my PDF file, and it will do exactly what I want. This doesn't seem to be true. For example, if my QML looks like:

    ApplicationWindow {
        title: qsTr("Qt5 QtQuick Demo")
        width: 640
        height: 480
        color: "whitesmoke"
    
        onClosing: main.shutdown()
    
        ColumnLayout {
            id: mainlayout
            anchors.fill: parent
    
            Image {
                id: pdfview
    
                Layout.fillWidth: true
                Layout.fillHeight: true
    
                source: "/home/user/Desktop/sample.pdf"
            }
        }
    }
    

    I get the following error:

    file:///home/user/Desktop/pdfview-project/qml/main.qml:18:9: QML Image: Error decoding: file:///home/user/Desktop/sample.pdf: Unsupported image format
    

    So that doesn't seem right to me. Does the QML Image object actually support PDF, or is that an error in the documentation of PdfDocument?

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      https://marketplace.qt.io/products/qtpdf

      It is an addon.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      1
      • M Offline
        M Offline
        malocascio
        wrote on last edited by
        #3

        Got it. So, if QtPDF is installed, then Image will support PDFs.

        I'd still prefer if the documentation could be clarified to state that explicitly. I'd be happy to submit a patch for the documents, if that can be done.

        jsulmJ 1 Reply Last reply
        0
        • M malocascio

          Got it. So, if QtPDF is installed, then Image will support PDFs.

          I'd still prefer if the documentation could be clarified to state that explicitly. I'd be happy to submit a patch for the documents, if that can be done.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @malocascio said in Error in PdfDocument documentation?:

          if that can be done

          It can.
          But I don't see why this should be explicitly mentioned in the doc: PDF is not an image format.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          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