blob: 69b85470d42347a43e32b4f9354ce4290eda0302 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Pdf
Window {
width: 320
height: 440
color: "lightgrey"
title: doc.source
visible: true
property real cellSize: 150
PdfDocument {
id: doc
source: "test.pdf"
}
GridView {
id: view
anchors.fill: parent
anchors.margins: 10
model: doc.pageModel
cellWidth: cellSize
cellHeight: cellSize
delegate: Item {
required property int index
required property string label
required property size pointSize
width: view.cellWidth
height: view.cellHeight
Rectangle {
id: paper
width: image.width
height: image.height
x: (parent.width - width) / 2
y: (parent.height - height - pageNumber.height) / 2
PdfPageImage {
id: image
document: doc
currentFrame: index
asynchronous: true
fillMode: Image.PreserveAspectFit
property bool landscape: pointSize.width > pointSize.height
width: landscape ? Math.min(view.cellWidth, pointSize.width)
: height * pointSize.width / pointSize.height
height: landscape ? width * pointSize.height / pointSize.width
: Math.min(view.cellHeight - pageNumber.height, pointSize.height)
sourceSize.width: width
sourceSize.height: height
}
}
Text {
id: pageNumber
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
text: "Page " + label
}
}
}
}
|