Comments (4)
Hi!
1- on android, the webview cannot access to the files located in the resources (.qrc
), and the pdf.js library (which is located in the qrc) cannot be also accessed directly.
So, to avoid this problem, the pdf.js
library folder is copied into the internal memory of the android device, which, instead, can be accessed by the webview. The viewer.html
that is displayed in the screen is the one saved in that folder. On android, that folder is recreated every time the app starts the first time, for this reason you see the view is always reset. A simple solution could be:
- save its page number somewhere (eg. in the
Settings
), and set that page on pdf load - load that value before showing the pdf in the
onPdfLoaded
. To avoid to see the animation due to the set of the page, you can delay the visibility of the page of some ms (eg. 300ms).
property int pageFromSettings: 4 // Load page from Settings
....
onPdfLoaded: {
// Set page from settings
pdfView.setPage(pageFromSettings)
// Pdf has been correctly loaded, ensure pdf view visibility
pdfView.visible = true
pdfView.opacity = 1
}
2- The pinch to zoom is not supported by the webview and mouse events are managed automatically by the pdf.js library, which, if i remember correctly, doesn't support that feature on android. However, you can zoom in/out with the + or - buttons.
from qt-pdf-viewer-library.
Thanks for your reply.
In addition, I can save the zoom value of the file, for example, 1.5. I want to restore the zoom value to 1.5 the next time I open the file. How can I do this? Including the rotation direction and the way the page is viewed, I want to restore their values the next time I open the file.
thank you
from qt-pdf-viewer-library.
I also found a problem about thumbnail refresh, that is, after opening some large pdf files, the thumbnail cannot be refreshed, and the thumbnail of the previous file is still displayed. I wonder if this is a bug?
from qt-pdf-viewer-library.
I want to restore the zoom value to 1.5 the next time I open the file. How can I do this? Including the rotation direction and the way the page is viewed, I want to restore their values the next time I open the file.
The methods to set those values are the following (see README
for all available methods or the sample app):
setScrollMode(scrollMode)
: sets the scroll mode of the documentsetScaleMode(scaleMode)
: sets the scale mode of the documentrotate(angle)
: rotates the document of the current anglezoomIn()
: zooms the document inzoomOut()
: zooms the document out
So, to update them from settings, you could do something like this:
property var settings: ... // Settings data
PdfView {
id: pdfView
onPdfLoaded: {
// Pdf has been correctly loaded, now set values from settings
pdfView.initFromSettings()
// Ensure pdf view visibility
pdfView.visible = true
pdfView.opacity = 1
}
function initFromSettings() {
pdfView.setPage(settings["page"])
pdfView.setScrollMode(settings["scrollMode"])
pdfView.rotate(settings["rotation"])
}
}
Note: when using settings, remember to set organization name, domain and application name in the main.cpp
, otherwise it will not save data (https://stackoverflow.com/questions/22672597/qml-qsettings-and-qml-cannot-save-load-settings).
QCoreApplication::setOrganizationName("MySoft");
QCoreApplication::setOrganizationDomain("mysoft.com");
QCoreApplication::setApplicationName("Star Runner");
I also found a problem about thumbnail refresh, that is, after opening some large pdf files, the thumbnail cannot be refreshed, and the thumbnail of the previous file is still displayed. I wonder if this is a bug?
Maybe i forgot to force the update on the thumbnails
property when updated. In qml array changes are not emitted by default (unless are undefined). This weekend i'll give it a look! :D
from qt-pdf-viewer-library.
Related Issues (7)
- About qt-pdf-viewer-library HOT 11
- module "it.ltdev.qt.qml.components" is not installed HOT 3
- A question about opening a new file. HOT 5
- Step-By-Step HOT 3
- Unable to display PDF HOT 10
- Web page not available HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qt-pdf-viewer-library.