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

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

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!
Josh



1 Reply

DB Dilli Babu Nandha Gopal Syncfusion Team 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.

Regards,

Dilli babu.


Loader.
Live Chat Icon For mobile
Up arrow icon