When converting the attached file Donow50pag.zip (46.1 KB)
to pdf, there are 204 pages generated, while in the original one only 47 pages are produced.
Thanks for using Aspose APIs.
We were able to observe this issue and logged it in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will let you know asap.
This issue has been logged as
- CELLSNET-45604 - Too many pages when converting to Pdf
The paper size is not set in sheet “Sheet1” in Microsoft Excel, it will use different paper size on different environments. On our end, it is paper A4. Using Workbook.Settings.PaperSize can change it.
There are many auto height rows and the cached height is very large. Use Sheet.AutoFitRows(true) to recalculate their heights.
Please try the following code:
C#
Workbook wb = new Workbook(srcFile);
Console.WriteLine(wb.DefaultStyle.Font);
//you can change the paper size to the size you see in your Microsoft Excel
wb.Settings.PaperSize = PaperSizeType.PaperA4;
Worksheet sheet = wb.Worksheets["Sheet1"];
sheet.AutoFitRows(true);
wb.Save("outFile.pdf");
Thanks, Shakeel.
The Sheet.AutoFitRows(true) did the trick.
Please close this case.
Thanks for your feedback and using the Aspose APIs.
It is good to know that your issue is now sorted out. Let us know if you encounter any other issue, we will be glad to look into it and help you further. We have also closed this ticket now.