develtar / qt-pdf-viewer-library

The qt-pdf-viewer-library is a qml wrapper of pdf.js library which allows you to render PDF files in a WebView. This library also works on Android devices, and it uses WebSocketServer, WebSocketTransport and WebChannel to exchange data between qml and the browser environment.
Apache License 2.0
42 stars 9 forks source link

Unable to display PDF #6

Open Astar-Li opened 1 year ago

Astar-Li commented 1 year ago

20230906204640

develtar commented 1 year ago

@Astar-Li could you provide the following info, please?

Astar-Li commented 1 year ago

@Astar-Li could you provide the following info, please?

  • have you tried the sample app first?
  • have you requested access to permissions via the permissions manager, like in the sample?
  • which qt version are you using?
  • on which android version are you testing the library?

@develtar Dear develtar

  • have you requested access to permissions via the permissions manager, like in the sample? Yes,I have tried the sample app first.It's run ok on Android 7 8 9 10 11 12 13 But after I put targetSdkVersion = 33, the above inaccessibility situation will result

  • have you requested access to permissions via the permissions manager, like in the sample? Yes, I applied for permission I even tested the pdf file inside the app because it doesn't require permissions, but the results are still the same

  • which qt version are you using? QT5.15.2 NDK :21.3.6528147

  • on which android version are you testing the library? API 33, Android 13


Here are the solutions I tried setAllowFileAccess Official website document explanation: Enables or disables file access within WebView. Note that this enables or disables file system access only. Assets and resources are still accessible using file:///android_asset and file:///android_res.

https://bugreports.qt.io/browse/QTBUG-97487

Astar-Li commented 1 year ago

But so far, I haven't found a way to setAllowFileAccess

Astar-Li commented 1 year ago

But so far, I haven't found a way to setAllowFileAccess

From API level 30 the native Android WebView will have file access disabled by default.

develtar commented 1 year ago

Thank you for the info!

I'll give it a look this weekend :)

develtar commented 1 year ago

@Astar-Li

Astar-Li commented 1 year ago

@Astar-Li

  • which JDK version are you using?
  • which SDK version are you using?

JDK:11.0.2

SDK :9.0

Android build platform SDK: android-33

Astar-Li commented 1 year ago

@develtar But my tests show that this is only related to targetSdkVersion, which appears when targetSdkVersion>= 30

develtar commented 1 year ago

@Astar-Li i haven't yet found a workaround to this issue: maybe the webview settings could be set natively using the QAndroidJniObject class, and accessing directly to the WebSettings method setAllowFileAccess.

Some of the links i consulted are the following:

If in the meantime you found a workaround, let me know or feel free to make a merge request!

develtar commented 10 months ago

@Astar-Li have you found a workaround?