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

Free Support Forum - aspose.com

Save Workbook to PDF in Landscape Mode


When saving a Workbook as a PDF type, is it possible to save it in landscape mode vs. portrait mode? And if so, could you please provide an example as to how to do it using the APIs? Thank you.


Well, you may specify each worksheet’s orientation type to landscape in the workbook before rendering to PDF.
Sample code:


var workbook = new Workbook(@"e:\test2\Book1.xlsx");

foreach (Worksheet sheet in workbook.Worksheets)


sheet.PageSetup.Orientation = PageOrientationType.Landscape;




Workbook workbook = new Workbook("Book1.xlsx");

for (int i = 0; i < workbook.getWorksheets().getCount(); i++ )





Hope, this helps a bit.

Thank you.


Is there a way to set it on the Book level so that you don’t have to loop through sheets? Also I marked this item as “Java”. Could you please provide the Java API version of the appropriate code snippet? Thanks.


Thanks for your posting and using Aspose.Cells.

We are afraid, this is not a Workbook level setting as we have tested it in Microsoft Excel 2016. This is a Worksheet level setting only, so you will have to iterate all worksheets and set their orientation to landscape one by one. Besides, we have updated the code to Java code in our previous post for your help. It should help you to set the sheet orientation in Java successfully. Let us know your feedback.

Thank you both.