Welcome Guest Search | Active Topics | Sign In | Register

EO.MVCToPdf RenderAsPDF not rendering Telerik objects Options
WMP
Posted: Tuesday, September 3, 2019 10:46:11 AM
Rank: Advanced Member
Groups: Member

Joined: 7/6/2011
Posts: 30
I am finding MVC to pdf doesn't seem to render Telerik objects in my MVC page. Is there a workaround for this please?

Quote:
[HttpPost]
[RenderAsPDF(AutoConvert = true)]
public ActionResult CompaniesToPdf()
{
//This works but doesn't render telerik
MVCToPDF.ResultFileName = "ParticipatingCompanies";
MVCToPDF.RenderAsPDF();
return View("CompaniesPdf");
}
eo_support
Posted: Wednesday, September 4, 2019 4:09:34 AM
Rank: Administration
Groups: Administration

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

We will try to setup a test environment here with Telerik control and see what we can find.

Thanks
WMP
Posted: Friday, September 6, 2019 6:58:24 AM
Rank: Advanced Member
Groups: Member

Joined: 7/6/2011
Posts: 30
Thank you for this. Did you have any luck?
eo_support
Posted: Tuesday, September 10, 2019 3:07:30 PM
Rank: Administration
Groups: Administration

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

We have setup a test environment with Telerik UI for ASP.NET MVC and it seems to be working fine. Our steps are as follow:

1. Install Telerik UI for ASP.NET MVC;
2. Start Visual Studio, using "Telerik ASP.NET MVC Application" project template to create a new project;
3. Select "Menu and Grid" style;
4. Add "EO.Pdf.Mvc.MVCToPDF.RegisterFilter(typeof(GlobalFilters));" to FilterConfig.RegisterGlobalFilters;
5. Add RenderAsPDF attribute to the Index controller method;

We then run the page and the PDF file is created correctly.

Note that a noticeable difference between the PDF rendering and a typical browser rendering is that the PDF render uses a much narrower "window" (due to the fact that a PDF page is typically much narrower than a browser window). Such narrower rendering window would often trigger the "mobile layout" of the page. As a test, you can simulate such result by resizing your browser window to a much narrow window and see if you see the same result.

It is possible for you to use a wider rendering window for EO.Pdf by setting HtmlToPdf.Options.ZoomLevel to a value less than 1. For example, you can add the following code in your controller:

Code: C#
HtmlToPdf.Options.ZoomLevel = 0.5f;

This will reduce the contents to half of the original size (for example, text will be 50% of its original size) but have the net effect of fitting more contents per page, which effectively increases the rendering window's pixel width.

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

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

Thanks!
WMP
Posted: Thursday, September 12, 2019 1:03:11 PM
Rank: Advanced Member
Groups: Member

Joined: 7/6/2011
Posts: 30
Ah fantastic, thank you. I didn't have FilterConfig.RegisterGlobalFilters set up right. It is working now! :D
eo_support
Posted: Thursday, September 12, 2019 4:39:34 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Great. Glad to hear that it's working for you.


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.