Welcome Guest Search | Active Topics | Sign In | Register

Export WebView as PDF Options
Andreas Müller
Posted: Monday, October 30, 2023 5:49:32 AM
Rank: Newbie
Groups: Member

Joined: 5/8/2020
Posts: 9
Hi Team,

till now we used the "Capture" method of the WebView object to save screenshots of the loaded web page. Our customers are complaining about this meanwhile, because it is an image an they can e.g. not use the text of the page later on.

So we wanted to change to export a PDF document directly. But we are not able to figure out a really good, working way. Here is our use-case:
User navigates to a web site and does some research. They are playing around with some filter etc. At a certain moment she wants to save the current content to her case.

- option 1 (currently used): use capture methode to export content into a image file. pro: content is "as is", so we capture what the user actually sees; pro: it is an image, text could not be used later on
- option 2: use HtmlToPdfSession in combination with GetHtml of the WebView and setting this in RunWebViewCallback export into a pdf. Problem is, that e.g. images are lost and result does not look the same
- option 3: use HtmlToPdfSession in combination with setting URL property of the WebView in RunWebViewCallback and export into a pdf. Problem is, that e.g. images are lost and result does not look the same; also cookies which were accepted before are asked again, because it is kind of new session. Also if user logged in, with this method she is not anymore.
- option 4: use print method to export as a pdf. This is not feasable, because we can not rely that a pdf printer is installed on customers machines. Additionally we would have to select the users the PDF printer to use, if also names would differ from machine to machine.

So currently we do not see a way to have a good quality PDF without any downside. Ideally we would like to see something like the HtmlToPdfSession where we just could provide the currently loaded and already fully rendered WebView which is shown to the user as a parameter. So that the currently visible side is just exported into a PDF.

Did we miss something, a parameter, on overload to simply export into a PDF?

Regards
Andreas
eo_support
Posted: Monday, October 30, 2023 1:12:33 PM
Rank: Administration
Groups: Administration

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

You did not miss anything. Option 4 is the best option but unfortunately we must add some method on our side in order to support it. We can look into it and see if we can add it. Note that once implemented, you will need both EO.WebBrowser license and EO.Pdf license in order to use this feature.

Thanks!
Andreas Müller
Posted: Thursday, November 2, 2023 7:04:13 AM
Rank: Newbie
Groups: Member

Joined: 5/8/2020
Posts: 9
Hi,

thanks for the information. About license: Yes, that was what we expected and we will the extend our license, if that feature will be available in a future release.

Regards
Andreas
eo_support
Posted: Friday, November 3, 2023 1:24:00 PM
Rank: Administration
Groups: Administration

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

We have posted a new build that added this function:

https://www.essentialobjects.com/doc/eo.pdf.htmltopdf.capture.html

Please let us know if this works for you.

Thanks!
Andreas Müller
Posted: Monday, November 6, 2023 4:24:18 AM
Rank: Newbie
Groups: Member

Joined: 5/8/2020
Posts: 9
Hi,

great to see how fast you act. Unfortunately it does not work for us as we understood it. We created a very simple sample app. It is WPF and we added a browser control and a textbox. We then just opened google.com and did a simple search. Behind a button click we have this code:
private void Button_Click(object sender, RoutedEventArgs e)
{
var pdfFilePath = System.IO.Path.ChangeExtension(System.IO.Path.GetTempFileName(), ".pdf");
HtmlToPdf.Capture(CtrWebView).PdfDocument.Save(pdfFilePath);
Process.Start(pdfFilePath);
}
CtrWebView is defined in this way:
<eo:WebView x:Name="CtrWebView" />

But the resulting PDF does not contain the content, which is currently visible to the user. In the view there are a couple of search results, the PDF shows only a text with something like "click here if you are not forwarded automatically".

Regards
Andreas
eo_support
Posted: Monday, November 6, 2023 9:47:52 AM
Rank: Administration
Groups: Administration

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

It appears Google did something special to prevent this. We will look into it and see what we can find.

Thanks!
Andreas Müller
Posted: Monday, November 6, 2023 9:57:45 AM
Rank: Newbie
Groups: Member

Joined: 5/8/2020
Posts: 9
Hi,

that's interesting. Google is not our primary site our users will use. We have some other sides, it was just what we used for a first test. We will try our own sites, which are important for our customers. We will come back with some news on that soon.

Regards
Andreas
eo_support
Posted: Monday, November 6, 2023 1:32:09 PM
Rank: Administration
Groups: Administration

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

We have found out the root cause why it did not work on Google's page. Our next build should work correctly for this case.

Thanks!
eo_support
Posted: Monday, November 13, 2023 1:32:33 PM
Rank: Administration
Groups: Administration

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

This is just to let you know that we have posted a new build (23.3.84) that should allow you to capture Google's output. You can download the new build from our download page.

Thanks!
Andreas Müller
Posted: Tuesday, January 23, 2024 9:50:12 AM
Rank: Newbie
Groups: Member

Joined: 5/8/2020
Posts: 9
Hi Team,

we tested with the latest release 2023.4.26.0, but we still have an issue. We are using this line to create the PDF:
HtmlToPdf.Capture(webView).PdfDocument.Save(filePath);
The resulting PDF has an encoding issue.

Special cases like the § symbol and also German Umlauts are not encoded correctly in the PDF.

We tried to capture this site, which contains a lot of § and umlauts:
https://dejure.org/gesetze/RVG/13.html

Regards
Andreas
eo_support
Posted: Tuesday, January 23, 2024 11:23:33 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
HI,

Our up coming 2024 release should resolve this issue. We are expecting it to be out in a week or two. We will reply here again once it is out.

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.