admin管理员组文章数量:1287596
Do you know how to share webView as PDF? I'm using io.github.kevinnzou:compose-webview-multiplatform for displaying webview and PrintManager for generating PDF. PrintManager is working very well: scaling, rendering and paging is done automatically and there is zero quality loss, but... it does not have share option. The question is how can I manage sharing document in my app? PrintManager requires interaction from user - he need to select location in which to save pdf first, it does not have any customization and callbacks, app can not event locate where user saved the pdf and event don't allow access for temporary generated PDF file that is rendered during preview.
I tried rendering PDF with PdfDocument and bitmap but its not rendering full webview page (only actually visible content) and there are some scaling, rendering issues and quality loses - but doing in that way it allows to render pdf immediately and share the file. Do you have any tips how I can do share pdf feature for webView? Is this even possible?
Do you know how to share webView as PDF? I'm using io.github.kevinnzou:compose-webview-multiplatform for displaying webview and PrintManager for generating PDF. PrintManager is working very well: scaling, rendering and paging is done automatically and there is zero quality loss, but... it does not have share option. The question is how can I manage sharing document in my app? PrintManager requires interaction from user - he need to select location in which to save pdf first, it does not have any customization and callbacks, app can not event locate where user saved the pdf and event don't allow access for temporary generated PDF file that is rendered during preview.
I tried rendering PDF with PdfDocument and bitmap but its not rendering full webview page (only actually visible content) and there are some scaling, rendering issues and quality loses - but doing in that way it allows to render pdf immediately and share the file. Do you have any tips how I can do share pdf feature for webView? Is this even possible?
Share Improve this question asked Feb 24 at 16:48 Piotr BartkowiakPiotr Bartkowiak 11 bronze badge 3- Not tried with compose of webview specifically, but it was easy with the Android View system to create high quality (non bitmap) PDF's that covered the entire content (including anything that would normally be off screen). More complicated was multi page documents (but I don't think that would work with webview as it's one view) – Andrew Commented Feb 24 at 17:13
- I also wondered if there is a way to access the temporary PDF file from PrintManager or get the location of the saved file. By default it is not available for security reasons, but the PrintManager solution is the best to ensure that the PDF file is rendered correctly with pagination. – Piotr Bartkowiak Commented Feb 26 at 9:25
- I suggest you look at android.googlesource or cs.android/android/platform/superproject/main as they have the source code and you should be able to find PrintManager and work out what it does and if there things you could do. – Andrew Commented Feb 26 at 9:58
1 Answer
Reset to default 0Did you tried with WebView's onDraw() method?
val bitmap = Bitmap.createBitmap(webView.width, webView.height, Bitmap.Config.ARGB_8888) val canvas = Canvas(bitmap) webView.draw(canvas)
本文标签: kotlinShare webView as PDF on AndroidStack Overflow
版权声明:本文标题:kotlin - Share webView as PDF on Android - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741252728a2366094.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论