Change page orientation PDF

The orientation property of a page is a viewer instruction. It is independent of the content. By setting page.Orientation to 90, we tell the viewer that this page should be displayed 90-degrees rotated.

Code sample to change the page orientation PDF

using (FileStream inFile = new FileStream("PackingLightBrochure.pdf", FileMode.Open, FileAccess.Read))
    // open the document
    Document document = new Document(inFile);

    // enumerate the pages 
    foreach (Page page in document.Pages)
        // change the orientation of the page
        page.Orientation = Orientation.Rotate90;

    // write the target document to disk
    using (FileStream outFile = new FileStream("output.pdf", FileMode.Create, FileAccess.Write))
Using inFile As New FileStream("PackingLightBrochure.pdf", FileMode.Open, FileAccess.Read)
   ' open the document
   Dim document As New Document(inFile)

   ' enumerate the pages 
   For Each page As Page In document.Pages
      ' change the orientation of the page
      page.Orientation = Orientation.Rotate90

   ' write the target document to disk
   Using outFile As New FileStream("output.pdf", FileMode.Create, FileAccess.Write)
   End Using
End Using

And then the resulting PDF will be rotated like so:

Change Orientation Pdf

Download PDFKit.NET 5.0
We will send you a download link
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download

We have sent an email with a download link. Alternatively, you may want to use the NuGet package manager to install our library.

Nuget ID

Use the NugetID and start right away, or download the package and install it handmatically