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

Free Support Forum - aspose.com

Convert excel to pdf width issue

I am trying to convert a excel to pdf use the code below, but I found the pdf converted by aspose seems not wide enouth than the pdf I save as pdf by MS excel. I have uploaded the excel and the screenshot that shows the difference. Please feel free to take a look, thank you!
Our aspose version is

Aspose.Cells.PdfSaveOptions saveOption = new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);
Aspose.Cells.Workbook docExcel = new Aspose.Cells.Workbook(sourceFile);
Aspose.Cells.AutoFitterOptions autoFitterOptions = new Aspose.Cells.AutoFitterOptions();
autoFitterOptions.OnlyAuto = true;
foreach (Aspose.Cells.Worksheet ws in docExcel.Worksheets)
docExcel.Save(outputPdfFile, saveOption);

image.png (75.2 KB)
test.7z (16.6 KB)


Thanks for the sample file and screenshot.

I tested your scenario/case using your template file. I generated the PDF file (attached). I then opened your template Excel file into MS Excel manually and generated the PDF manually in it. Both PDFs are same.
out1.pdf (53.3 KB)

I am using our latest version of Aspose.Cells for .NET. Since you are using an older version of the APIs, so we cannot evaluate your issue. We recommend you to kindly try using our latest version/fix: Aspose.Cells for .NET v22.12 (Download | NuGet). Let us know if you still find the issue with latest version/fix.

Hi, as you said, I upgrade my aspose to the latest version, could you see the three screenshot below:
output1.pdf is your pdf; test.pdf is the one that I save as from the ms excel file; f8ab8721f3524977825ffed3e01a2253.pdf is the one that I export after I upgrade my local aspose; It seems the page size for output1.pdf and f8ab8721f3524977825ffed3e01a2253.pdf are the same, but different the test.pdf which save as from the ms excel file. Please check it one more time, thank you!
image.png (85.9 KB)
image.png (81.6 KB)
image.png (86.7 KB)


Please find attached PDFs one is generated with MS Excel (“test_MSExcel.pdf”) manually and other is generated by Aspose.Cells (“output_AsposeCells.pdf”) on my end. Please open both files into Adobe acrobat and you will notice both have same page size.
test_MSExcel.pdf (31.6 KB)
out1.pdf (53.3 KB)

So, you may try using MS Excel 2007 or 2016 to open the Excel file and render to PDF. Let us know if you find any difference regarding page size.