Webview2 PrintToPdfAsync generates pdf having blank pages before contents

Vasanth Ramakrishnan 0 Reputation points
2023-11-02T11:48:48.23+00:00

Hi..

Blank pages are generated by webview2 PrintToPdfAsync during the below scenario.

  An outer table and an image table inside it( image have larger size than current page size)

 and image table have page-break-inside:avoid used.

 When webview2  PrintToPdfAsyn generates pdf, results blank pages before image .

 Nested tables having large contents size inside ( larger than current page size) always results blank pages

 How to avoid this blank pages issues?
Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
1,913 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Wenying Lu-MSFT 875 Reputation points Microsoft Vendor
    2023-11-03T05:28:24.1066667+00:00

    Hi @Vasanth Ramakrishnan ,

    You could try to use CoreWebView2PrintSettings.MediaSize Property specifies the media size for a print.

    However, if media size is Custom, you should set the PageWidth and PageHeight.

    If the issue persists, in order for us to investigate this further, could you please provide the minimal code example that can help us to reproduce the issue on our end?


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Regards,

    Wenying Lu