Welcome Guest Search | Active Topics | Sign In | Register

got problem to call MVCToPDF when printing Ajax load document Options
Jerry
Posted: Monday, June 1, 2015 5:44:29 PM
Rank: Newbie
Groups: Member

Joined: 6/1/2015
Posts: 3
Please see sample code below //view <div id="grid"></div> $("#grid").kendoGrid({ columns: [ { field: "name" } ], dataSource: [ { name: "Beverages", name: "Food", }, ] } ], }); //controller public ActionResult PdfPrint(Guid id) { var model= GetModelById(id); MVCToPDF.ResultFileName = "pdf.pdf"; MVCToPDF.RenderAsPDF(); return View(model); } When I call PdfPrint action, all other page component will be printed out except this grid, which is rendered by Kendo UI. Is there way to print out this kind of Javascript rendering component in MVC? I'm using EO.Pdf version 6.0.20.2 Thanks,
eo_support
Posted: Tuesday, June 2, 2015 11:51:25 AM
Rank: Administration
Groups: Administration

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

Please try to increase the value of HtmlToPdf.Options.MinLoadWaitTime. By default the converter will wait for a very short time after the page is loaded before it starts converting the page into PDF. However that time may not be enough for the script in your page to finish the AJAX call and populate the page with the actual data. So in that case if you increase HtmlToPdf.Options.MinLoadWaitTime it might resolve the issue for you. You should set that property immediately before you call RenderAsPDF.

Thanks!
Jerry
Posted: Tuesday, June 2, 2015 12:22:33 PM
Rank: Newbie
Groups: Member

Joined: 6/1/2015
Posts: 3
Hi,

Thanks for your help. I added HtmlToPdf.Options.MinLoadWaitTime = 30000; statement just before MVCToPDF.RenderAsPDF(); but looks like it does not work properly, I still cannot see the grid rendered by kendo ui. Anything wrong?

Thanks,
eo_support
Posted: Tuesday, June 2, 2015 12:43:59 PM
Rank: Administration
Groups: Administration

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

Please try two things:

1. Monitor the debug output to see if the page run into any JavaScript error. See here for more details (check the "Debug Console" section):

http://www.essentialobjects.com/doc/4/htmltopdf/js.aspx

2. Add bind method. See this post for sample code:

http://www.essentialobjects.com/forum/postst8340_EOPdf--SVG-renders-blank-using-NVD3.aspx

Please let us know if those resolve the issue for you.

Thanks!
Jerry
Posted: Wednesday, June 3, 2015 2:27:05 PM
Rank: Newbie
Groups: Member

Joined: 6/1/2015
Posts: 3
Hi,

Thanks for your suggestion. However, these tips cannot solve the issue. I finally figured out that is because I have several Kendo Grid rendered on one page and some of them are rendered by client side Kendo Grid while others are rendered by server side Kendo Grid MVC. such mixed condition will cause all the grids which are rendered by client side Kendo Grid cannot display on PDF output. After changed all grids to either client side or server side, the problem is solved.

I don't know why it happened but think it is better to let you know such conditions so that you can reproduce this issue and find a better solution in your application.

Thanks,
eo_support
Posted: Wednesday, June 3, 2015 2:47:38 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Great. I am glad to hear that you found out a workaround. Thank you very much for sharing the information with us!


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.