←Select platform

RotationAngle Property

Summary
A value that contain the rotation angle of this page.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public int RotationAngle { get; set; } 
@property (nonatomic, assign) NSInteger rotationAngle; // 100th of a degree 
public int getRotationAngle() 
public void setRotationAngle(int value) 
public: 
property int RotationAngle { 
   int get(); 
   void set (    int ); 
} 
RotationAngle # get and set (OcrPageAutoPreprocessValues) 

Property Value

The rotation angle of this page in hundredths of a degree.

Remarks

IOcrPage.AutoPreprocess will update this value if OcrAutoPreprocessPageCommand.Rotate was used and the page was rotated.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Ocr; 
using Leadtools.Forms.Common; 
using Leadtools.Document.Writer; 
using Leadtools.WinForms; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
 
public static void SetOverlayImageExample() 
{ 
   var originalFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"); 
   var imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1_Deskewed.tif"); 
   var outFileName = Path.Combine(LEAD_VARS.ImagesDir, "result.pdf"); 
 
   using (var ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
   { 
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
 
      // Mimic having an image that is de-skewed 
      using (var rasterImage = ocrEngine.RasterCodecsInstance.Load(originalFileName, 1)) 
      { 
         // Rotate the image by 5 degrees to mimic deskew 
         var rotateCommand = new RotateCommand(5 * 100, RotateCommandFlags.None, RasterColor.FromKnownColor(RasterKnownColor.White)); 
         rotateCommand.Run(rasterImage); 
         ocrEngine.RasterCodecsInstance.Save(rasterImage, imageFileName, RasterImageFormat.CcittGroup4, 1); 
      } 
 
      // Now we are ready. We will create a PDF for the result with image over text overlay. And we will intercept creating 
      // the overlay and use the original image instead 
 
      // Use PDF with image/text option 
      var pdfOptions = ocrEngine.DocumentWriterInstance.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions; 
      pdfOptions.ImageOverText = true; 
      ocrEngine.DocumentWriterInstance.SetOptions(DocumentFormat.Pdf, pdfOptions); 
 
      // Create an OCR AutoRecognize job 
      var jobData = new OcrAutoRecognizeJobData 
      { 
         ImageFileName = imageFileName, 
         FirstPageNumber = 1, 
         LastPageNumber = -1, 
         DocumentFileName = outFileName, 
         Format = DocumentFormat.Pdf 
      }; 
 
      var autoRecognizeManager = ocrEngine.AutoRecognizeManager; 
      var job = autoRecognizeManager.CreateJob(jobData); 
 
      // Setup pre-processing commands 
      autoRecognizeManager.EnableTrace = true; 
      autoRecognizeManager.PreprocessPageCommands.Clear(); 
      autoRecognizeManager.PreprocessPageCommands.Add(OcrAutoPreprocessPageCommand.All); 
      OcrAutoRecognizeManagerJobStatus status; 
 
      EventHandler<OcrAutoRecognizeJobOperationEventArgs> jobOperation = (sender, e) => 
      { 
         if (e.Operation == OcrAutoRecognizeManagerJobOperation.SavePage) 
         { 
            if (!e.PostOperation) 
            { 
               // Get the pre-processing values for the page 
               var values = e.Page.GetPreprocessValues(); 
               // Show the status of it 
               Console.WriteLine("Page:{0} IsInverted:{1} RotationAngle:{2} DeskewAngle{3}", e.ImagePageNumber, values.IsInverted, values.RotationAngle, values.DeskewAngle); 
 
               // Load the original image from disk 
               var overlayImage = e.Document.RasterCodecsInstance.Load(e.Job.JobData.ImageFileName, e.ImagePageNumber); 
 
               // Apply to the image 
               if (values.RotationAngle != 0) 
                  new RotateCommand(values.RotationAngle, RotateCommandFlags.None, RasterColor.FromKnownColor(RasterKnownColor.White)).Run(overlayImage); 
               if (values.IsInverted) 
                  new InvertCommand().Run(overlayImage); 
 
               e.Page.SetOverlayImage(overlayImage); 
            } 
         } 
      }; 
 
      autoRecognizeManager.JobOperation += jobOperation; 
 
      try 
      { 
         status = autoRecognizeManager.RunJob(job); 
      } 
      finally 
      { 
         autoRecognizeManager.JobOperation -= jobOperation; 
      } 
 
      Console.WriteLine(status); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS22\Bin\Common\OcrLEADRuntime"; 
} 
Requirements

Target Platforms

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

Leadtools.Ocr Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.