Rotate PDF using Go

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

Rotate PDF Pages with Go

Do you need to rotate the PDF? Programmatic modification of PDF documents is an essential part of modern digital workflows. Go 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 Go via C++, which is an easy and secure toolkit used to work with PDF. To install and use Aspose.PDF for Go via C++, click on Download Aspose.PDF for Go.

How to Rotate PDF documents


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

  1. Import Libraries.
  2. Open a PDF File.
  3. Rotate a Page in the PDF using RotatePage function.
  4. Saving the Rotated PDF.
  5. Clean up resource

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

Rotate PDF - Go

This sample code shows how to Rotate PDF Pages - Go

Input file:

File not added

Output format:

PDF

Output file:


  package main

  import "github.com/aspose-pdf/aspose-pdf-go-cpp"
  import "log"

  func main() {
    // Open(filename string) opens a PDF-document with filename
    pdf, err := asposepdf.Open("sample.pdf")
    if err != nil {
      log.Fatal(err)
    }
    // PageRotate(num int32, rotation int32) rotates page
    err = pdf.PageRotate(1, asposepdf.RotationOn180)
    if err != nil {
      log.Fatal(err)
    }
    // SaveAs(filename string) saves previously opened PDF-document with new filename
    err = pdf.SaveAs("sample_page1_Rotate.pdf")
    if err != nil {
      log.Fatal(err)
    }
    // Close() releases allocated resources for PDF-document
    defer pdf.Close()
  }

About Aspose.PDF for Go via C++ API

The Aspose.PDF for Go 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 Go via C++ API on Documentation and examples on how to use tool.