←Select platform

Rotate Method

Summary

Rotates this page by the specified angle.

Syntax
C#
VB
C++
public void Rotate( 
   int angle 
) 
Public Sub Rotate( 
   ByVal angle As Integer 
) 
public:  
   void Rotate( 
      Int32 angle 
   ) 

Parameters

angle

Rotation angle in degrees. Positive values will rotate the page clockwise and negative values will rotate the page counter-clockwise. Must be in increment of 90 degrees.

Remarks

This method changes the value of ViewPerspective based on the previous value and angle.

Refer to Document Page Transformation for more information.

Example

This example will load a document, rotates and flips a couple of pages before exporting it to a new PDF.

C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Document.Writer; 
using Leadtools.Svg; 
using LeadtoolsExamples.Common; 
using Leadtools.Document; 
using Leadtools.Caching; 
using Leadtools.Annotations.Engine; 
using Leadtools.Ocr; 
using Leadtools.Barcode; 
using Leadtools.Document.Converter; 
 
public static void DocumentPageRotateExample() 
{ 
   var documentUri = new Uri("https://demo.leadtools.com/images/pdf/leadtools.pdf"); 
   string documentFile = Path.Combine(ImagesPath.Path, "PagesModified.pdf"); 
 
   // Load this document 
   var loadDocumentOptions = new LoadDocumentOptions(); 
   using (var document = DocumentFactory.LoadFromUri(documentUri, loadDocumentOptions)) 
   { 
      // Documents are read-only by default and we cannot modify them. Fix that 
      document.IsReadOnly = false; 
 
      DocumentPage page; 
 
      // This document has 5 pages 
 
      // Rotate the page by 90 degrees clockwise 
      page = document.Pages[0]; 
      page.Rotate(90); 
      // Flip the second page vertically 
      page = document.Pages[1]; 
      page.Flip(); 
      // Delete the third page 
      page = document.Pages[2]; 
      page.IsDeleted = true; 
 
      // we will save it as a new PDF, this file should contain 4 pages with the first rotated by 90 and the second flipped vertically 
      using (var documentConverter = new DocumentConverter()) 
      { 
         var jobData = new DocumentConverterJobData(); 
         // The loaded document is our input 
         jobData.Document = document; 
         // We want PDF as output 
         jobData.DocumentFormat = DocumentFormat.Pdf; 
         // Into this file 
         jobData.OutputDocumentFileName = documentFile; 
 
         var job = documentConverter.Jobs.CreateJob(jobData); 
         documentConverter.Jobs.RunJob(job); 
      } 
   } 
 
   // Show the result 
   Process.Start(documentFile); 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Document.Writer 
Imports Leadtools.Svg 
Imports Leadtools.Document 
Imports Leadtools.Caching 
Imports Leadtools.Annotations.Engine 
Imports Leadtools.Barcode 
Imports Leadtools.Ocr 
Imports LeadtoolsDocumentExamples.LeadtoolsExamples.Common 
Imports Leadtools.Document.Converter 
 
Public Shared Sub DocumentPageRotateExample() 
   Dim documentUri As New Uri("https://demo.leadtools.com/images/pdf/leadtools.pdf") 
   Dim documentFile As String = Path.Combine(ImagesPath.Path, "PagesModified.pdf") 
 
   ' Load this document 
   Dim loadDocumentOptions As New LoadDocumentOptions() 
   Using document As LEADDocument = DocumentFactory.LoadFromUri(documentUri, loadDocumentOptions) 
      ' Documents are read-only by default And we cannot modify them. Fix that 
      document.IsReadOnly = False 
 
      Dim page As DocumentPage 
 
      ' This document has 5 pages 
 
      ' Rotate the page by 90 degrees clockwise 
      page = document.Pages(0) 
      page.Rotate(90) 
      ' Flip the second page vertically 
      page = document.Pages(1) 
      page.Flip() 
      ' Delete the third page 
      page = document.Pages(2) 
      page.IsDeleted = True 
 
      ' we will save it as a New PDF, this file should contain 4 pages with the first rotated by 90 And the second flipped vertically 
      Using documentConverter As New DocumentConverter() 
         Dim jobData As New DocumentConverterJobData() 
         ' The loaded document Is our input 
         jobData.Document = document 
         ' We want PDF as output 
         jobData.DocumentFormat = DocumentFormat.Pdf 
         ' Into this file 
         jobData.OutputDocumentFileName = documentFile 
 
         Dim job As DocumentConverterJob = documentConverter.Jobs.CreateJob(jobData) 
         documentConverter.Jobs.RunJob(job) 
      End Using 
   End Using 
 
   ' Show the result 
   Process.Start(documentFile) 
End Sub 

Requirements

Target Platforms

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly