Rotate PDF pages in C++

Set the rotation of every PDF page to 90 degrees using Aspose.PDF for C++.

Set all pages to 90-degree rotation

The example sets an absolute rotation value of 90 degrees rather than adding 90 degrees to the existing rotation.

  1. Open the input PDF as a Document.
  2. Iterate through every Page.
  3. Set Rotate to on90 from Rotation.
  4. Save the result with Save().

#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/Page.h>
#include <Aspose.PDF.Cpp/PageCollection.h>
#include <Aspose.PDF.Cpp/Rotation.h>

using namespace System;
using namespace Aspose::Pdf;

// Port of RotatePagesExamples.rotatePage.
void RotatePage(System::String inputFile, System::String outputFile)
{
    auto document = MakeObject<Document>(inputFile);

    for (const auto& page : document->get_Pages()) {
        page->set_Rotate(Rotation::on90);
    }
    document->Save(outputFile);
}