android - Cannot call Pdf from Html in my WebView -
i have terms , conditions page uses webview display terms in html. loaded -
webview webview = (webview) findviewbyid(r.id.webview); webview.getsettings().setbuiltinzoomcontrols(true); webview.getsettings().setsupportzoom(true); webview.getsettings().setusewideviewport(true); webview.loadurl("file:///android_asset/termsandconditions.html");
also in assets folder maintermsandconditions.pdf called link in html this
<a href="file:///android_asset/maintermsandconditions.pdf">main terms</a>
the problem though pdf in assets folder, nothing happens when click link. i've tried adding target="_blank" still won't work.
what doing wrong
if whant dispaly pdf in webview free have options:
1) using google .you have host file , load special link app:
url = "https://docs.google.com/gview?embedded=true&url=" + urlofyourpdf;
2) use pdf.js. have import lib , add assets folder. in html have link library. can set in body pdf file assets.
you can try : https://github.com/googlesamples/android-pdfrendererbasic, api 21 , above.
Comments
Post a Comment