Loading Pdf File
Android natively doesn't have option to render pdf file. So rendering it is a bit tricky but solutions exist.
Loading web pdf
To load a pdf file, we can make use of google drive's embedded url utility to achieve similar functionality on both iOS and Android.
Just prefix your url with "http://docs.google.com/gview?embedded=true&url=" and call LoadUrl of web view.
// Assume you have a webView instance (IWebView) already created
void LoadPdfInWebView()
{
string yourPdfUrl = "https://yourwebsite.com/sample.pdf";
string urlPath = "http://docs.google.com/gview?embedded=true&url=" + yourPdfUrl;
//...
webView.LoadUrl(URLString.URLWithPath(urlPath));
}Loading local pdf
Here we will make use of Mozilla's pdf.js project for rendering the pdf locally.
Place the above mozilla.zip folder in Assets/StreamingAssets folder
Unzip its contents and delete mozilla.zip
Prefix your local pdf file path with below string (PDF_VIEWER_PATH)
Last updated
Was this helpful?