Open ic005k opened 1 year ago
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:
Settings
), and set that page on pdf loadload 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.
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
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?
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 outSo, 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
Hello, I have two details as follows: