Welcome Guest Search | Active Topics | Sign In | Register

Webview to PDF with session Options
Ron Ward
Posted: Friday, May 18, 2018 7:17:33 PM
Rank: Newbie
Groups: Member

Joined: 5/11/2018
Posts: 3
Hi ,

my c# testing project includes several things:
1. Login to a website
2. Browse the website after authentication
3. Print the webview to a XPS document
4. Print the webview to a PDF document

1. Can you give me an example to print the current webview's rendered page to a pdf using EO.pdf with the existing webview session?

2. How to use Webview.print() to print to file using XPS without prompt to ask for a filename?

I still receive a prompt to input a filename using the below code:

void WebView2_BeforePrint(object sender, BeforePrintEventArgs e)
{

e.PrinterSettings.PrinterName = "Microsoft XPS Printer";
e.PrinterSettings.PrintFileName = @"C:\testprinttofile.xps";
e.PrinterSettings.DefaultPageSettings.PaperSize = new PaperSize("210 x 297 mm", 800, 800);
e.PrinterSettings.DefaultPageSettings.Landscape = false;
e.PrinterSettings.PrintToFile = true;
e.Continue(false);

}
eo_support
Posted: Monday, May 21, 2018 11:45:41 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

Unfortunately neither feature is supported now.

As to print WebView to PDF, you can do everything you do with the WebView with EO.Pdf (such as loading the page and login) with this method:

https://www.essentialobjects.com/doc/eo.pdf.htmltopdfsession.runwebviewcallback.aspx

However the WebView used by EO.Pdf is always maintained by EO.Pdf and it is not visible to the end user. This is due to a number of reasons. For example, for performance reason, EO.Pdf maintains a pool of WebView objects. It also automatically resizes the WebView during the conversion process as an attempt to find out the optimal zoom level. All these makes it challenging to work with a WebView that's already on screen.

As to print to XPS, we only support a few properties in PrinterSettings class (it was probably a bad choice to use this class at the first place). This has to do with the limited settings the Chromium browser engine's printer setting class provides. PrintFileName is not passed to the browser engine at all because the browser engine's printer setting class does not have this.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.