Rotate PDF Pages Using C#
This topic describes how to update or change the page orientation of pages in an existing PDF file programmatically with C#.
The following code snippet also work with Aspose.PDF.Drawing library.
Change Page Orientation
From Aspose.PDF for .NET 9.6.0 release, we have added great new features like changing the page orientation from landscape to portrait and vice versa. To change the page orientation, set the page’s MediaBox using the following code snippet. You can also change page orientation by setting rotation angle using Rotate() method.
Fitting the Page Content to the New Page Orientation
Please note that when using the above code snippet, some of the document’s content might be cut because the page height is decreased. To avoid this, increase width proportionally and leave the height intact. Example of calculations:
Besides the above approach, consider using the PdfPageEditor facade which can apply zoom to the page contents).