Skip to content

Commit 8d1a2e4

Browse files
committed
bugfix
1 parent 2aebbd6 commit 8d1a2e4

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

apdfjs-lib/src/main/java/com/github/truefedex/apdfjs/PDFJSView.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,23 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
5757
}
5858

5959
public void loadFromAssets(String pdfAssetsPath) {
60-
apdfjsInterface.fileName = "file:///android_asset/" + Uri.encode(pdfAssetsPath, "UTF-8");
61-
webView.loadUrl(PDFJS_ASSETS_PATH);
60+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
61+
webView.loadUrl("file:///android_asset/pdfjs-1.7.225-dist/web/viewer.html?file=file:///android_asset/" +
62+
Uri.encode(pdfAssetsPath, "UTF-8"));
63+
} else {
64+
apdfjsInterface.fileName = "file:///android_asset/" + pdfAssetsPath;
65+
webView.loadUrl(PDFJS_ASSETS_PATH);
66+
}
6267
}
6368

6469
public void loadFromFile(String pdfFilePath) {
65-
apdfjsInterface.fileName = Uri.encode(pdfFilePath, "UTF-8");
66-
webView.loadUrl(PDFJS_ASSETS_PATH);
70+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
71+
webView.loadUrl("file:///android_asset/pdfjs-1.7.225-dist/web/viewer.html?file=file://" +
72+
Uri.encode(pdfFilePath, "UTF-8"));
73+
} else {
74+
apdfjsInterface.fileName = "file://" + pdfFilePath;
75+
webView.loadUrl(PDFJS_ASSETS_PATH);
76+
}
6777
}
6878

6979
public class APDFJSInterface {

0 commit comments

Comments
 (0)