Welcome Guest Search | Active Topics | Sign In | Register

aspx to PDF doesnt show javascript binded htmls Options
ENEC Dev Team
Posted: Thursday, June 28, 2018 4:20:14 AM
Rank: Newbie
Groups: Member

Joined: 6/28/2018
Posts: 6
Hi Support Team,

I am new to this component and we purchansed the tool last week to convert aspx to PDF.

The problem i am facing is , most of the contents in aspx page is populated via javascript. whiile converting to pdf using a button click it only shows the headers which is already in aspx page as static texts. it doesnt show the dynamic htmls i have binded using javascript. i can see it properly in the web page, but when converting to pdf it doesnt show. Also i am not seeing background images, banner images etc. In pdf i can see only black font colors and backgrounds. i am using boot strap

Pleas ehelp
eo_support
Posted: Thursday, June 28, 2018 3:05:48 PM
Rank: Administration
Groups: Administration

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

If you use ASPXToPDF to render the PDF, the easiest way for you to troubleshoot is to comment out RenderAsPDF call first. After you comment it out, the result will render to screen instead of to PDF. Check if this rendering result is correct. If this render result is wrong, then this has to do with your ASP.NET code and you must fix this first. Once you fix that, uncomment RenderAsPDF and the result should be the same as what was on the screen.

If you still have problems after that, you can try to isolate the problem into a test project and send the test project to us. Once we have that we will be happy to investigate further. See here for more details on sending test project to us:

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

Thanks!
ENEC Dev Team
Posted: Sunday, July 1, 2018 1:33:14 AM
Rank: Newbie
Groups: Member

Joined: 6/28/2018
Posts: 6
Hi,

Can you be more specific. I am seeing the page correctly. I have a button in the page and i am rendering the pdf in that button click. But when the pdf is generated it has only the header contents which is static and not the dynamic contents. Also the pdf not taking the styles. is it a problem with the reference url since in aspx page the reference is in relative path. Do we need to give full url in the style references? Pleas ehelp i am stuck

Thanks
Janesh
ENEC Dev Team
Posted: Sunday, July 1, 2018 1:35:18 AM
Rank: Newbie
Groups: Member

Joined: 6/28/2018
Posts: 6
For security reasons i cant submit the project. Also the code contains internal web service call to populate dynamic page
ENEC Dev Team
Posted: Sunday, July 1, 2018 2:44:30 AM
Rank: Newbie
Groups: Member

Joined: 6/28/2018
Posts: 6
Just to update you with my trouble shooting, i can see the contents are not displayed because the content div is display:none in the aspx, but after binding the values i am making it display block from the javascript. and i can see it all good in the page, but converting it to pdf when button clicks it all appears as initial styles with blank content.

as i can see eo is creating an iframe on the load to push the content and then pdf is generated using the iframe. But how can i say eo to create the iframe on my button click since the content is changed during rendition.

Thanks
Janesh
eo_support
Posted: Monday, July 2, 2018 8:49:38 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
There are two common causes for such cases:

1. The converter started before your JavaScript code (that dynamically populates contents) since it does not know when your JavaScript code has finished populating contents. The easiest way to avoid such problem is to increase HtmlToPdf.Options.MinLoadWaitTime. Alternatively, you can use manual trigger:

https://www.essentialobjects.com/doc/pdf/htmltopdf/trigger.aspx

2. The base Url is wrong. ASPXToPDF will automatically populate HtmlToPdf.Options.BaseUrl based on your current Url. This Url can be wrong in some cases if you have intermediate structures that are invisible to the end user (such as load balancer). In that case you can handle ASPXToPDF's BeforeRender event and set HtmlToPdf.Options.BaseUrl to the correct value.

Hope this helps. Please let us know if you still have any questions.

Thanks!
ENEC Dev Team
Posted: Wednesday, July 4, 2018 3:22:24 AM
Rank: Newbie
Groups: Member

Joined: 6/28/2018
Posts: 6
Thank you again,

IS this applicable to aspx pages as well this is what i am doing

void btnGeneratePDF_Click(object sender, EventArgs e)
{
EO.Pdf.Runtime.AddLicense("code goes here");
ASPXToPDF1.RenderAsPDF();
}

Because the links says to add below to by javascript

if (window.eoapi && eoapi.isEOPdf())
eoapi.convert();

So do i need to do the able like this

void btnGeneratePDF_Click(object sender, EventArgs e)
{
EO.Pdf.Runtime.AddLicense("code goes here");

HtmlToPdf.Options.TriggerMode = HtmlToPdfTriggerMode.Manual;

ASPXToPDF1.RenderAsPDF();


}
eo_support
Posted: Wednesday, July 4, 2018 8:28:01 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Yes. Your code is correct. However make sure you only call eoapi.convert() AFTER you have loaded all your JavaScript binded contents --- this is the whole point of eopai.convert().
ENEC Dev Team
Posted: Tuesday, July 10, 2018 2:39:26 AM
Rank: Newbie
Groups: Member

Joined: 6/28/2018
Posts: 6
No luck. always my window.eoapi is undefined. Also eoapi also undefined. Please help am stuck

My export button click taking long time showing loading and then a error. Seems like nothing working for me :(
eo_support
Posted: Wednesday, July 11, 2018 5:08:30 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
What version do you use? eoapi does not exist in early versions.


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.