We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

View to Pdf in landscape format

Thread ID:





144827 May 24,2019 01:09 PM UTC May 27,2019 08:52 AM UTC ASP.NET Core - EJ 2 3
Tags: PDF
Joachim Francois
Asked On May 24, 2019 01:09 PM UTC


I've been using the View To Pdf in asp.net Core to generate pdf reports without any issues, perfect tool! 

But  one of the current exports needs a landscape format and that's not rendering as fine as it should.
The view only shows several very large table rows before creating a new page each time.

I've followed the View To Pdf example from Syncfusion to get to grips with the default rendering (portrait) and was wondering if there would be an alternative example available for landscape format exports?

Thanks in advance!

Prakash Viswanathan [Syncfusion]
Replied On May 27, 2019 05:38 AM UTC

Hi Joachim, 
Thank you for contacting Syncfusion support.  
We can specify the orientation of PDF document in Orientation property of WebKitConverterSettings. We have tried the view to PDF conversion with landscape orientation and it is working fine in our end. Please refer below code snippet to set the landscape orientation for the conversion.  
//Initialize HTML to PDF converter  
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); 
WebKitConverterSettings settings = new WebKitConverterSettings(); 
//Set PDF page orientation 
settings.Orientation = PdfPageOrientation.Landscape; 
//Set WebKit path 
settings.WebKitPath = Path.Combine(_hostingEnvironment.ContentRootPath, "QtBinariesWindows"); 
//Assign WebKit settings to HTML converter 
htmlConverter.ConverterSettings = settings; 
//Convert URL to PDF 
PdfDocument document = htmlConverter.Convert("http://localhost:53756"); 
MemoryStream stream = new MemoryStream(); 
return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "Output.pdf"); 
If still you are facing the same issue, please provide more details about the issue such as input HTML, output PDF documents in both orientation, complete code snippet, environment details (OS, bit version, culture settings etc.,) to reproduce the issue in our end. So that it will be helpful for us to analyse and assist you further on this.  

Prakash V 

Joachim Francois
Replied On May 27, 2019 07:32 AM UTC

Hi Prakash,

Thanks for the reply!

As mentioned in my initial post, this was indeed working fine. But there was a weird scaling going on as the table in my HTML view wasn't properly displayed when turning the page to Landscape orientation.
I've played around a bit with the other settings and obtained a decent scaling by adding the below to the code;

settings.WebKitViewPort = new Size(1500,0);

That assited in scaling the page properly when landscape orientation was requested.

Prakash Viswanathan [Syncfusion]
Replied On May 27, 2019 08:52 AM UTC

Hi Joachim, 
Thank you for your update. We are glad to know that you are achieving your requirement by adjusting WebKitViewport size.  
Please let us know if you need any further assistance on this.  
Prakash V 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon