summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-08-22 09:59:38 +0200
committerMichal Klocek <michal.klocek@qt.io>2019-11-25 13:00:56 +0100
commit25fb3b04706752932e33b9d96fab74fa8469400d (patch)
treebceb9b3d9f793ddcc55c5f0d120da6c974bcedad /tests/manual
parente3802e913e1d6a3694d0084a35516145e2be32df (diff)
Add a QImageIOHandler to render PDF with QtQuick Image
Now you can use Image in QML to display the first page of a PDF file by default. (The implementation is very similar to the handler plugin in the QtSVG module.) To display other pages, you can set the new currentFrame property that is being added to Image in 5.14. QPdfIOHandler uses its own instance of QPdfDocument to do the rendering. An instance will be created each time the image needs to read a frame from the file (on creation; each time the currentFrame property is changed; each time sourceSize is changed to require a different resolution rendering). This approach is not as efficient as it would be to share the QPdfDocument instance among multiple Images that are rendering different pages at the same time, as well as sharing with the QML Document declaration that we plan to add. However, if you set asynchronous: true, each Image will render its page from the PDF in its own thread. PDFium is not thread-safe, so sharing the QPdfDocument among multiple threads is not safe. It may be possible to make it safe by having a dedicated PDF-rendering thread, but that is not yet done in this patch. Change-Id: I7a1f8cd7bd5b8f93d45fa9350752b2d9356b04fe Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/quick/pdf/simplest.qml54
-rw-r--r--tests/manual/quick/pdf/test.pdfbin0 -> 80045 bytes
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/manual/quick/pdf/simplest.qml b/tests/manual/quick/pdf/simplest.qml
new file mode 100644
index 000000000..05d8c53c4
--- /dev/null
+++ b/tests/manual/quick/pdf/simplest.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.14
+
+Image {
+ source: "test.pdf"
+}
diff --git a/tests/manual/quick/pdf/test.pdf b/tests/manual/quick/pdf/test.pdf
new file mode 100644
index 000000000..a9dc1bc29
--- /dev/null
+++ b/tests/manual/quick/pdf/test.pdf
Binary files differ