Rotate PDF using Rust

Change PDF page orientation. Use Aspose.PDF for Rust via C++ to modify PDF documents programmatically

Rotate PDF Pages with Rust

Do you need to rotate the PDF? Programmatic modification of PDF documents is an essential part of modern digital workflows. Rust libraries like Aspose.PDF – are stand-alone solutions that don’t rely on other software and are ready for commercial use. To rotate PDF files, we’ll use Aspose.PDF for Rust via C++, which is an easy and secure toolkit used to work with PDF. To install and use Aspose.PDF for Rust via C++, click on Download Aspose.PDF for Rust.

How to Rotate PDF documents


You need Aspose.PDF for Rust via C++ to try the code in your environment.

  1. Import the Necessary Modules.
  2. The code imports Document and Rotation from the asposepdf crate, which provides functionality for working with PDFs.
  3. Rotate a Page.
  4. Save the Rotated PDF.
  5. Error Handling.

If you want to rotate PDF files for your tasks, this solution can help. With this powerful Aspose.PDF Rust via C++ library, you can update or change the page orientation of pages while keeping its quality. This professional tool uses Rust to rotate PDF effectively. The following example demonstrates how to rotate PDF document in Rust:

Rotate PDF - Rust

This sample code shows how to Rotate PDF Pages - Rust

Input file:

File not added

Output format:

PDF

Output file:

use asposepdf::{Document, Rotation};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open a PDF-document from file
    let pdf = Document::open("sample.pdf")?;

    // Rotate page
    pdf.page_rotate(1, Rotation::On180)?;

    // Save the previously opened PDF-document with new filename
    pdf.save_as("sample_page1_rotate.pdf")?;

    Ok(())
}

About Aspose.PDF for Rust via C++ API

The Aspose.PDF for Rust via C++ is a powerful toolkit that allows developers to manipulate PDF files directly and helps do various tasks for PDF. Contains unique features for converting PDF to other formats.

You can find more information about Aspose.PDF for Rust via C++ API on Documentation and examples on how to use tool.