dart_pdf
dart_pdf copied to clipboard
In android 13 Printing.convertHtml() function not working. App got stuck at that point and generate nothing!
Describe the bug
i have other device samsung c7 pro(android version 8) and in that device this function works perfectly fine but got error in my other device samsung m34.
i share below code i call this lines of code it will print htmlToParse:-"
Hello!
" then i wait for a 5 min but this function doesn't return any thing in htmlString variable!App got stuck at Printing.convertHtml(htmlToParse).
i use printing: ^5.11.0 my flutter sdk 3.10.5
To Reproduce Code snippet to reproduce the behavior:
htmlToParse="<html><body><p>Hello!</p></body></html>";
print("htmlToParse:-$htmlToParse");
htmlString = await Printing.convertHtml(html: htmlToParse);
print("htmlString:-$htmlString");
how can i solve this issue ??
Same issues, it is working in Android 13 Samsung, but stuck in Android 13 Google Pixel, i'm tried debug it, in Java method adatapter.write - not response
in android 13 device working? which device?
in android 13 device working?
I have 2 device with 13 Android, Google Pixel and Samsung s22 ultra, and in Samsung that work perfrectly but in Google Pixel method convertHtml is not work it stuck
can you share code? just that function!
same problem here
after uninstall the webview update (https://play.google.com/store/apps/details?id=com.google.android.webview) it working again.
Means issue resolve in your app?
after uninstall the webview update (https://play.google.com/store/apps/details?id=com.google.android.webview) it working again.
thanks, it is work for me, bug in webview system it is very funny :D
Means issue resolve in your app?
it is not application issue, it is issue android webview component in devices, all people who get this bug should be remove update android webview component in system.
I think this issue can be close because library make all good
But how?? Can you pls provide step to solve I am new to flutter so
Actually i also use webview_flutter for webview content in my app
But how?? Can you pls provide step to solve I am new to flutter so
Actually i also use webview_flutter for webview content in my app
In device where it is not work, need open https://play.google.com/store/apps/details?id=com.google.android.webview and click button "remove" thats all, dart pdf use PdfDocumentAdapter with system WebView
@mozomig that's not the solution! for app it is not good say to user uninstall the android webview from playstore and it works
need to find solution from library side!
@mozomig that's not the solution! for app it is not good say to user uninstall the android webview from playstore and it works
need to find solution from library side!
Yep, you can write issue for Google, when they fixed webview component and updated it, this issue will be fixed :) it is not issue this library it is issue webview, we don't have solution for fixed in library side it is impossible
Does anyone know if there is any ticket that we can track regarding this Android system webview bug? I tried with Android system webview beta and dev and they are also not working, so it is not looking good so far.
there is no other option so uninstall Android system webview from device and it will work
I did it, but this can't be a serious permanent solution?
i also discuss this point in previous chat. Now what is the permanent solution that i don't know. i am also new in flutter so waiting for solution
I think I'll remove this convertHtml function and point people to another library to do the same thing.
It's not available on all platforms and the result is not consistent. There are bug reports that cannot be fixed because they use the system's WebView to render the HTML, which is vendor-specific.
Any update on this?
Not yet brother!! Developer says android webview side issue and he is right bcoz in ios its working fine!! So need to wait for android side or library side solution!!
@bhaumik1111 But Need to resolve this issue from this package side only. As an app developer, we can't tell app users to remove android system webview update from their phone to use this package based feature
Any update on a potential fix and/or alternative library?
No brother! @jelen-HC
I think I'll remove this convertHtml function and point people to another library to do the same thing.
It's not available on all platforms and the result is not consistent. There are bug reports that cannot be fixed because they use the system's WebView to render the HTML, which is vendor-specific.
It will be unfortunate if this functionality is dropped. This is the only option to get a decent PDF that looks the same as the original html in a webview. The suggested alternative is not anywhere close to that and is broken in many ways.
In my tests the current Printing.convertHtml()
works on iOS, MacOS and Android below 13. Unfortunately it does not work on Android 13 and 14.
However there is a html_to_pdf which is also using Android's webview for html to PDF rendering but works on Android 13 and 14.
After a quick comparison I came up with this change below and with this change the Printing.convertHtml()
now also works on Android 13 and 14 in my tests.
Hopefully you could use this and consider reverting deprecation of this essential feature.
@ekuleshov I see. Maybe I can move this code to a new package. This way it's opt-in and obvious that it doesn't work with Windows, Linux, and web.
@ekuleshov I see. Maybe I can move this code to a new package. This way it's opt-in and obvious that it doesn't work with Windows, Linux, and web.
Don'y you already have Printing.info()
declaring supported capabilities? This doesn't seem different from canRaster
or canPrint
.
Still, people report as a but that it doesn't work on some platforms, without checking Printing.info().
I suppose you can throw an exception saying that feature X is not supported on the current platform. That could be the same of all flags in the PrintingInfo
.
~~BTW, for the web support you might be able to use html2pdf.js - it works with jsPDF, which I think you also using.~~
For the web support it seems like jsPDF works well.
It needs these two dependencies:
<script src="jspdf.umd.js"></script>
<script src="html2canvas.js"></script>
then the following js code produces a very decent PDF document:
window.jsPDF = window.jspdf.jsPDF;
var doc = new jsPDF();
doc.html(document.body, {
callback: function (doc) {
doc.save();
},
width: 135,
windowWidth: 600
});
+1 to fix the problem and revert the deprecation...