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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Auto-Scale PDF page size based on content to cleanly fit on single page

Thread ID:





119373 Jun 11,2015 03:01 PM UTC Jun 12,2015 05:38 AM UTC ASP.NET Web Forms 1
Tags: XlsIO
Josh Schwartzberg
Asked On June 11, 2015 03:01 PM UTC

I need to fit all the excel export content on a single pdf page (as we are not using PDF for printing to paper) - regardless of the number of rows of data in excel.

When I setup the worksheet like so:
ws.PageSetup.Orientation = ExcelPageOrientation.Landscape;
ws.PageSetup.FitToPagesWide = 1;
ws.PageSetup.FitToPagesWide = 1;
//Trying largest paper size I could find, but still not nearly big enough.
ws.PageSetup.PaperSize = ExcelPaperSize.A2Paper; 
var converter = new ExcelToPdfConverter(ws);
var pdf = converter.Convert();

And perform the convert to pdf, I get a bunch of overlapped text: screenshot here: http://i.imgur.com/d7IIYds.png

We are currently using SautinSoft.ExcelToPDF, and it automatically scales the paper size based on the content and provides our correct behavior - but the product is slow and support is poort.  

Is there a way in syncfusion to do this?

Thank you!

Dilli Babu Nandha Gopal [Syncfusion]
Replied On June 12, 2015 05:38 AM UTC

Hi Josh,

Thank you for your interest in Syncfusion products.

Yes, your requirement can be achieved by using our ExcelTopdfConverter. To print the entire worksheet in a single page, you must set the LayoutOption property in ExcelToPdfConverterSettings class to LayoutOptions.FitSheetOnOnePage. This implementation is described in below code snippet.

Code Snippet:

ExcelToPdfConverter converter = new ExcelToPdfConverter(book);

//Intialize the ExcelToPdfconverterSettings

ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();

//Set the Layout Options for the output Pdf page.

settings.LayoutOptions = LayoutOptions.FitSheetOnOnePage;

PdfDocument pdfDoc = new PdfDocument();  
pdfDoc = converter.Convert(settings);

We have also shared a sample for your reference which can be downloaded from following link.

Sample link: http://www.syncfusion.com/downloads/support/directtrac/140141/ze/Excel_to_PDF-463146983

Since you have created Direct-trac support incident regarding the same query, you can follow up that incident for any further queries regarding this.


Dilli babu.


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