Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrintAsync for pdf files prints blank pages #3779

Closed
AndyInside opened this issue Sep 12, 2023 · 5 comments
Closed

PrintAsync for pdf files prints blank pages #3779

AndyInside opened this issue Sep 12, 2023 · 5 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@AndyInside
Copy link

AndyInside commented Sep 12, 2023

Description

Version
SDK: 1.0.1938.49
Runtime: 116.0.1938.76
Framework: .NET6
OS: Windows 10

PrintAsync for pdf files prints blank pages, it seems that print starts before pdf is fully loaded, and there is no way to find it out. only Thread.Sleep before printing helps. I use 10 seconds timeout , but anyway sometimes it happens,
please help! thanks!

AB#46632667

@AndyInside AndyInside added the bug Something isn't working label Sep 12, 2023
@vickiez vickiez added the tracked We are tracking this work internally. label Sep 20, 2023
@fabiorocha fabiorocha assigned monica-ch and unassigned vickiez Sep 22, 2023
@monica-ch
Copy link
Contributor

@AndyInside I am trying to understand when your app calls the WebView2 PrintAsync API?

@akoessler
Copy link

akoessler commented Sep 27, 2023

I too encountered this problem today.

We want to print a pdf file completely in background from a console application, and I have tried that today using PrintAsync.
That worked well, but also only if I wait some time after the navigation, before the print.
If I do not wait, the result is a blank page.
Waiting for NavigationCompleted event or other events does not help.

For my small test pdf file i needed to wait at least 500ms for it to be then printed correctly.

See my example code and my test pdf file as attachment.
Program.txt
test.pdf

SDK: 1.0.2045.28
Runtime: 117.0.2045.41
.NET 4.7.2
Windows 10

@AndyInside
Copy link
Author

@AndyInside I am trying to understand when your app calls the WebView2 PrintAsync API?

  1. CoreWebView2.Navigate("1.pdf")
  2. await CoreWebView2.PrintToPdfAsync()

Navigation to pdf file ignores any state events like NavigationCompleted, PrintToPdfAsync starts printing immediately before pdf is loaded ( so prints empty pages)

@docfresh
Copy link

Can confirm, the code from @akoessler is reproducible for me. Sometimes the only information available is the "OtherError" print status ... can we get additional information from the CoreWebView2PrintStatus class? Like what the other error actually is.

@nishitha-burman
Copy link
Collaborator

Fixed in version 123.0.2376.0+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

6 participants