Maunik
Maunik

Reputation: 86

Android: Unable to Print/PDF html document from WebView (version: 86.0.4240.75)

// Get a PrintManager instance
PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);

// Get a print adapter instance
PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();

// Create a print job with name and adapter instance
String jobName = getString(R.string.app_name) + " Document";
PrintAttributes.Builder builder = new PrintAttributes.Builder();
builder.setMediaSize(PrintAttributes.MediaSize.ISO_A4);
PrintJob printJob = printManager.print(jobName, printAdapter, builder.build());

Error Message: "Sorry, That didn't work. Try Again."

With the latest update of Android System WebView(version: 86.0.4240.75), unable to generate pdf or print using createPrintDocumentAdapter from my webview of html document. With older version of Android System Webview, it works good.

Please let us know if anyone has solution for this?

PDF/Print error

Upvotes: 3

Views: 2068

Answers (3)

Maunik
Maunik

Reputation: 86

This issue is fixed on the latest version of the Chrome/Android System WebView app. Google has already released an update on Playstore and we confirmed that this issue is resolved with it.

Track issue here

Upvotes: 2

Chris
Chris

Reputation: 11

I not sure is it works for everybody, I faced this issue too on my mobile app, what I do is:

  1. Go to settings and select Apps
  2. Select Apps and select show system processes from more option
  3. Search for Android System WebView
  4. Disable it and enable it again I don't know why it somehow downgrades the web view version, after this I found that my printing features are working now, you might give it a try

Upvotes: 1

Marcus G
Marcus G

Reputation: 16

We got the same problem with our Cordova Applications. We use the pdf-generator 2.1.1 for Cordova. The Pdf can be loaded the first time after the app got started, if it gets closed and opened again, we get the same error. If I close the app completly and restart it, I can open it one time again. Maybe a caching problem in the webview or something like that.

I guess the only fix would be a new update for the webview, that fixes the problem. The bug also happens sometimes when i try to save a email in the gmail app as pdf.

Upvotes: 0

Related Questions