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
close icon

View to Pdf in landscape format


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!

3 Replies

PV Prakash Viswanathan Syncfusion Team 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 

JF Joachim Francois 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.

PV Prakash Viswanathan Syncfusion Team 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 

Live Chat Icon For mobile
Up arrow icon