Welcome Guest Search | Active Topics | Sign In | Register

EO.PDF Error Options
Olivier MATROT
Posted: Monday, December 13, 2021 10:18:44 AM
Rank: Member
Groups: Member

Joined: 10/18/2019
Posts: 11
I'm trying to convert an HTML page and sometimes, I have sometimes the following error:
Failed to call JavaScript extension (jsStartEOPdfConvert)

I need guidelines to be able to provide you with a reproduction sample.

Thanks in advance.
eo_support
Posted: Monday, December 13, 2021 6:55:52 PM
Rank: Administration
Groups: Administration

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

What version do you use? Do you have a way to reproduce it? This should occur very rarely as it usually means that part of the browser engine is in in the process of shutting down. This can happen either as the conversion engine recycles the browser engine or the browser engine crashes. In case of recycling browser engine we do manage the life cycle of the browser engine so it should not impact the conversion. In case of the browser engine crash, you could receive this error.

The easiest way for you to recover from this error is put a try catch block and then run the conversion again ---- obviously this does not resolve the root of the problem but maybe good enough for some scenarios. If you do wish us to investigate the root issue, please try to create a reproducing test app and send the test app to us and we will be happy to investigate further. See here for more details:

https://www.essentialobjects.com/forum/test_project.aspx

Thanks!
Olivier MATROT
Posted: Tuesday, December 14, 2021 9:40:36 AM
Rank: Member
Groups: Member

Joined: 10/18/2019
Posts: 11
Hi,
In production I'm using version 2021.0.18.0.

In Development, we are currently validating version 2021.3.18.0 x64. The problem is that wih this version the following code does not work:

Quote:
//Start the conversion. Note that this is only necessary
//when HtmlToPdf.Options.TriggerMode is set Manual or Dual.
//The default value is Auto, so the conversion starts
//automatically.
//You may also use variable "eoapi" to check whether the page
//is running inside the converter so that the custom triggering
//code will not run inside a regular browser because variable
//"eoapi" does not exist in a regular browser
if (window.eoapi && eoapi.isEOPdf())
eoapi.convert();


=> window.eoapi is defined, but is an empty object with no convert method.

In both cases, HtmlToPdf.Options.TriggerMode is set to Manual.

eo_support
Posted: Tuesday, December 14, 2021 10:18:00 AM
Rank: Administration
Groups: Administration

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

We tested this on our end and we do see eoapi with all the methods. We run the following code:

Code: C#
HtmlToPdf.Options.TriggerMode = HtmlToPdfTriggerMode.Manual;
EO.WebBrowser.WebView.ShowDebugUI();
HtmlToPdf.ConvertUrl("http://www.google.com", new PdfDocument());


You can then follow the steps here to access the debug UI:

https://www.essentialobjects.com/doc/webbrowser/advanced/debug#debug_ui

Once you open the debug UI, you can go to the "Source" tab to use the watch window to examine the value of eoapi and you should see convert method does exist.

Could it be the page you are trying to convert have script code that intentionally overwrite eoapi variable?

Thanks!

Olivier MATROT
Posted: Tuesday, December 14, 2021 10:26:54 AM
Rank: Member
Groups: Member

Joined: 10/18/2019
Posts: 11
I see that you're converting in a console application.
I'm doing it in a Web API. It's all that can add right now.

EXIST_ISOEPDF ... it's a boolean(false)
eo_support
Posted: Tuesday, December 14, 2021 10:41:25 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
It doesn't matter whether it's a console application or inside a WebAPI application. The HTML to PDF has its own built-in browser engine and it works the same way regardless what type of application you are running. The sample application uses console application only because this way you can see the debug UI easily. If you wish to access the debug UI in your Web API app, you can use the built in remote debug feature to access the same debug interface as listed at the bottom part of the same documentation page posted above.
Olivier MATROT
Posted: Monday, December 20, 2021 8:27:31 AM
Rank: Member
Groups: Member

Joined: 10/18/2019
Posts: 11
Hello again, here is an Angular 12 project to reproduce the problem.

Please create the following directory before launching the web API: C:\Temp\SamplePDF

The SPA will allow you to display a table, the same table in a new tab (as an HTML document that will be the source of the PDF convertion) and finally a button to invoke EOPdf.


In the file EOPdf.js this works with the follwing code:


Quote:
function jsIsEOPdf() {
// return window.eoapi ? true : false;
return (window.eoapi && eoapi.isEOPdf() ? true : false);
}

function jsStartEOPdfConvert() {
// if (window.eoapi) {
if (window.eoapi && eoapi.isEOPdf()) {
eoapi.convert();
return true;
}
return false;
}


But it fails and goes in timeout with this one:

Quote:
function jsIsEOPdf() {
return window.eoapi ? true : false;
// return (window.eoapi && eoapi.isEOPdf() ? true : false);
}



function jsStartEOPdfConvert() {
// if (window.eoapi && eoapi.isEOPdf()) {
if (window.eoapi) {
eoapi.convert();
return true;
}
return false;
}
eo_support
Posted: Monday, December 20, 2021 5:11:58 PM
Rank: Administration
Groups: Administration

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

We ran your test project here and we do not see any problems. We start your Anguar app, then go to "localhost:4200" and click "Create PDF" and the PDF file is sucessfully created.

Additionally, you can run the built-in debugger by adding

Code: C#
EO.WebBrowser.WebView.ShowDebugUI();


To your API.Program.Main method before you start your API server. You will be able to use the built-in debug UI to examine and debug the page inside the converter.

Thanks!
Olivier MATROT
Posted: Tuesday, December 21, 2021 9:19:17 AM
Rank: Member
Groups: Member

Joined: 10/18/2019
Posts: 11
Ok there seems to be different behaviors between machines with eoapi.isEOPdf() that is sometimes true, sometimes false. What could explain that ?
eo_support
Posted: Tuesday, December 21, 2021 10:41:08 AM
Rank: Administration
Groups: Administration

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

There shouldn't be. eoapi.isEOPdf() always returns true when the page is running inside the HTML to PDF converter. To summarize:

1. If you run the page in Google Chrome, then eoapi will be undefined;
2. If you run the page in EO.WebBrowser, then eoapi will be defined and eoapi.isEOPdf() will return false;
3. If you run the page in EO.Pdf HTML to PDF converter, then eoapi will be defined and eoapi.isEOPdf() will return true;

Hope this clears up.

Thanks!
Olivier MATROT
Posted: Monday, January 3, 2022 8:38:52 AM
Rank: Member
Groups: Member

Joined: 10/18/2019
Posts: 11
I've updated the sample.pdf that is produced on one of our machine in the GitHub repo.
It shows that isEOFdf() return false.

EXIST_ISEOPDF...it's a boolean (false)

https://github.com/omatrot/test-EOPdf/blob/master/sample.pdf
eo_support
Posted: Monday, January 3, 2022 9:40:05 AM
Rank: Administration
Groups: Administration

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

I am not sure what else we can tell you --- We have tested the test project you sent to us and it is working correctly. If you still have problems, you can try:

1. Use the debugger feature we previously told you to debug the code;
2. Set up a test project on your server where you CAN reproduce the problem and provide remote access to us to that server. That way we can test it on your server in order to see the problem;

We can not tell you anything based on the result PDF file.

Thanks!
Olivier MATROT
Posted: Monday, January 10, 2022 4:20:14 AM
Rank: Member
Groups: Member

Joined: 10/18/2019
Posts: 11
What is exactly you need to be able to diagnose the problem?
We could deploy an azure VM for you with the application deployed on it.
You would deploy VS Community and run the app from a clone of the github repo if needed?

eo_support
Posted: Monday, January 10, 2022 10:00:28 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
Olivier MATROT wrote:
What is exactly you need to be able to diagnose the problem?
We could deploy an azure VM for you with the application deployed on it.
You would deploy VS Community and run the app from a clone of the github repo if needed?



Hi,

Yes. You can deploy an azure VM with the test project you posted on github we will be happy to take a look. We have already tried to run the github repo you posted in our environment and we are not able to reproduce the problem.

We did recently fix a time out error which may indirect cause the issue you are experiencing and have a new build that should fix that issue. So we would suggest you to updat to that build as well. We will PM you with the download location of that build.

Thanks!
Olivier MATROT
Posted: Wednesday, January 12, 2022 2:56:08 AM
Rank: Member
Groups: Member

Joined: 10/18/2019
Posts: 11
Hello,
We've created an online environment where you can exhibit the problem.
Please tell me where I can privately send you the credentials and procedure?
Thanks.
eo_support
Posted: Wednesday, January 12, 2022 8:55:51 AM
Rank: Administration
Groups: Administration

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

You can reply the private message that we sent you the new build with all the details. Those messages are not public.

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.