xamarin.android - Draw PDF out of WebView Xamarin Android -


i have string contains html object , use following code draw pdf of resulted webpage in xamarin android.

android.webkit.webview webpage = new  android.webkit.webview(application.context); int width = 2102; int height = 2973;  webpage.layout(0, 0, width, height); webpage.loaddata(htmlstring, "text/html", "utf-8"); webpage.setwebviewclient(new webviewcallback(pdffilepath)); 

webviewcallback class inherits webviewclient , has following method gets called webview ready:

public override void onpagefinished(android.webkit.webview mywebview, string url) {     pdfdocument document = new pdfdocument();     pdfdocument.page page = document.startpage(new pdfdocument.pageinfo.builder(2120, 3000, 1).create());     mywebview.draw(page.canvas);     document.finishpage(page);     stream filestream = new memorystream();     filestream fos = null;     try     {         fos = new filestream(filenamewithpath, filemode.openorcreate);         document.writeto(filestream);         fos.write(((memorystream)filestream).toarray(), 0, (int)filestream.length);         fos.flush();         fos.close();     }     catch(exception x)     {          //do     } } 

problem though webview seems load blank pdf. ideas?

could suggest simliar way using xamarin.forms.webview instead of android.webkit.webview?


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -