Unsolved Error in PdfDocument documentation?
-
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 anImage
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 thesource
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 ofPdfDocument
? -
https://marketplace.qt.io/products/qtpdf
It is an addon.
-
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.
-
@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.