We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert excel-file to PDF with specified size

How can I convert an excel-file to a PDF-file with pages of A4-size?

Can you supply me with a c# code snippet


Please try the following code.


string path = @“F:\source.xlsx”;

Workbook workbook = new Workbook(path);

workbook.Worksheets[0].PageSetup.PaperSize = PaperSizeType.PaperA4;

workbook.Save(path + “.out.pdf”);


I think you may try to use PageSetup options to set the paper size to A2 and then convert your workbook to PDF, see the document for reference:

Sample code:

//Instantiating a workboo and open an existing file
Workbook workbook = new Workbook("Book1.xls");

//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];

//Setting the paper size to A4
worksheet.PageSetup.PaperSize = PaperSizeType.PaperA4;

//Save the PDF file