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

Free Support Forum - aspose.com

How to change the Orientation in pdf page sizes dynamically in Aspose C#

How to change the Orientation(from Portrait to Landscape and from Landscape to Portrait) with different pdf page sizes dynamically in aspose C#


Are you using Aspose.Page to generate PDF from EPS/XPS files? Please specify the Aspose API which you are using so that we can share our feedback with you accordingly.

Iam trying to change the existing pdf page size and orientation(from Portrait to Landscape and from Landscape to Portrait) with aspose(Aspose.PDF(21.9.0)) C#


Please check the below sections of the API documentation in order to achieve your requirements:

Page Content is not fitting ​properly after applied the landscape


Would you please share the sample PDF along with complete code snippet that you have tried to change the orientation? We will test the scenario in our environment and address it accordingly.

Hi Team,

Please find attached sample code and pdf files.

Thanks & Regards,
Lavanya.Complete Code (PDF Page size and Orientation).docx (12.8 KB)
PPAD.pdf (986.1 KB)
938-Zincovit-Buccal Tablets-ffddfrdrd-12-1 Ply Flat Label-Angola-3M Pharmaceuticals-MMM.pdf (2.9 KB)2 PLY.pdf (1.9 MB)


Can you please share what is the definition of PageSize variable in your code as you are using it in if condition? Also, your code involves pdfDocument1 variable which was never initialized before. Please share complete runnable code snippet so that we can further proceed to assist you.