gpt4 book ai didi

c# - Android WebView 中的 pdfjs 在滚动时崩溃

转载 作者:行者123 更新时间:2023-11-30 01:39:36 28 4
gpt4 key购买 nike

我已将 pdf.js 添加到我的 Android 项目(Visual Studio 2015、Xamarin)中,以在 WebView 组件中显示 pdf。使用以下 Cod 加载示例 pdf。

        WebView wv = FindViewById<WebView>(Resource.Id.webView1);
wv.SetWebChromeClient(new WebChromeClient());
wv.Settings.JavaScriptEnabled = true;
wv.Settings.AllowUniversalAccessFromFileURLs = true;
wv.LoadUrl("file:///android_asset/pdfviewer/viewer.html?file=http://www.orimi.com/pdf-test.pdf");

但是当我尝试向下滚动 pdf 时,整个应用程序崩溃了。以下行来自调试日志。

Loaded assembly: System.dll [External] Der Thread 'Unknown' (0x2) hat mit Code 0 (0x0) geendet. 01-08 11:41:48.763 W/cr.BindingManager( 5994): Cannot call determinedVisibility() - never saw a connection for the pid: 5994 [INFO:CONSOLE(0)] "The provided value 'moz-chunked-arraybuffer' is not a valid enum value of type XMLHttpRequestResponseType.", source: (0) 01-08 11:41:49.359 I/chromium( 5994): [INFO:CONSOLE(0)] "The provided value 'moz-chunked-arraybuffer' is not a valid enum value of type XMLHttpRequestResponseType.", source: (0) [INFO:CONSOLE(946)] "Uncaught (in promise) TypeError: Cannot read property 'getItem' of null", source: file:///android_asset/pdfviewer/viewer.js (946) 01-08 11:41:49.540 I/chromium( 5994): [INFO:CONSOLE(946)] "Uncaught (in promise) TypeError: Cannot read property 'getItem' of null", source: file:///android_asset/pdfviewer/viewer.js (946) [INFO:CONSOLE(0)] "Handler added to rejected promise", source: file:///android_asset/pdfviewer/viewer.html?file=http://www.orimi.com/pdf-test.pdf (0) 01-08 11:41:49.565 W/cr.BindingManager( 5994): Cannot call determinedVisibility() - never saw a connection for the pid: 5994 01-08 11:41:49.565 I/chromium( 5994): [INFO:CONSOLE(0)] "Handler added to rejected promise", source: file:///android_asset/pdfviewer/viewer.html?file=http://www.orimi.com/pdf-test.pdf (0) [INFO:CONSOLE(7007)] "TypeError: Cannot read property 'getItem' of null", source: file:///android_asset/pdfviewer/viewer.js (7007) 01-08 11:41:49.566 I/chromium( 5994): [INFO:CONSOLE(7007)] "TypeError: Cannot read property 'getItem' of null", source: file:///android_asset/pdfviewer/viewer.js (7007) [INFO:CONSOLE(946)] "Uncaught (in promise) TypeError: Cannot read property 'getItem' of null", source: file:///android_asset/pdfviewer/viewer.js (946) 01-08 11:41:49.607 I/chromium( 5994): [INFO:CONSOLE(946)] "Uncaught (in promise) TypeError: Cannot read property 'getItem' of null", source: file:///android_asset/pdfviewer/viewer.js (946) [INFO:CONSOLE(7104)] "PDF c21f21ea44c1e2ed2581435fa5a2dcce [1.6 Acrobat Distiller 7.0.5 (Windows) / Acrobat PDFMaker 7.0.7 for Word] (PDF.js: 1.2.109)", source: file:///android_asset/pdfviewer/viewer.js (7104) 01-08 11:41:49.607 I/chromium( 5994): [INFO:CONSOLE(7104)] "PDF c21f21ea44c1e2ed2581435fa5a2dcce [1.6 Acrobat Distiller 7.0.5 (Windows) / Acrobat PDFMaker 7.0.7 for Word] (PDF.js: 1.2.109)", source: file:///android_asset/pdfviewer/viewer.js (7104) [INFO:CONSOLE(946)] "Uncaught (in promise) TypeError: Cannot read property 'getItem' of null", source: file:///android_asset/pdfviewer/viewer.js (946) 01-08 11:41:49.667 I/chromium( 5994): [INFO:CONSOLE(946)] "Uncaught (in promise) TypeError: Cannot read property 'getItem' of null", source: file:///android_asset/pdfviewer/viewer.js (946)

这是 viewer.js 函数的一个 fragment (第 946 行)

    _readFromStorage: function ViewHistory_readFromStorage() {
return new Promise(function (resolve) {
resolve(localStorage.getItem('database')); (Line 946)
});
},

有没有人有想法?

最佳答案

这似乎是一个 Android 问题。尝试启用 DOM 存储。

wv.Settings.DomStorageEnabled = true;

https://developer.xamarin.com/api/property/Android.Webkit.WebSettings.DomStorageEnabled/

关于c# - Android WebView 中的 pdfjs 在滚动时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34675252/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com