-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a14f00
commit 3ad7d30
Showing
8 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
OCR/.NET/Get-image-rotation-angle-from-OCR/Get-image-rotation-angle-from-OCR.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.3.32819.101 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Get-image-rotation-angle-from-OCR", "Get-image-rotation-angle-from-OCR\Get-image-rotation-angle-from-OCR.csproj", "{166945E9-DA34-4693-B891-BC5BA23BD990}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{166945E9-DA34-4693-B891-BC5BA23BD990}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{166945E9-DA34-4693-B891-BC5BA23BD990}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{166945E9-DA34-4693-B891-BC5BA23BD990}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{166945E9-DA34-4693-B891-BC5BA23BD990}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {512C0288-3F23-4E95-A770-4A809BC41D5E} | ||
EndGlobalSection | ||
EndGlobal |
15 changes: 15 additions & 0 deletions
15
...angle-from-OCR/Get-image-rotation-angle-from-OCR/Get-image-rotation-angle-from-OCR.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<RootNamespace>Get_image_rotation_angle_from_OCR</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.PDF.OCR.NET" Version="23.1.38" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+206 KB
OCR/.NET/Get-image-rotation-angle-from-OCR/Get-image-rotation-angle-from-OCR/Input.pdf
Binary file not shown.
41 changes: 41 additions & 0 deletions
41
OCR/.NET/Get-image-rotation-angle-from-OCR/Get-image-rotation-angle-from-OCR/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
|
||
using Syncfusion.OCRProcessor; | ||
using Syncfusion.Pdf; | ||
using Syncfusion.Pdf.Graphics; | ||
using Syncfusion.Pdf.Parsing; | ||
using System.Reflection.Metadata; | ||
|
||
//Initialize the OCR processor. | ||
using (OCRProcessor processor = new OCRProcessor()) | ||
{ | ||
//Get the stream from an image file. | ||
FileStream stream = new FileStream(@"../../../Input.pdf", FileMode.Open); | ||
//Set the OCR language to process. | ||
PdfLoadedDocument document = new PdfLoadedDocument(stream); | ||
//Set the OCR language. | ||
processor.Settings.Language = Languages.English; | ||
//Set the Unicode font to preserve the Unicode characters in a PDF document. | ||
processor.TesseractPath = @"../../../TesseractBinaries/"; | ||
processor.Settings.PageSegment = PageSegMode.AutoOsd; | ||
processor.PerformOCR(document, 0, 0, @"../../../Tessdata", out OCRLayoutResult result); | ||
float angle = 0; | ||
if (result != null) | ||
{ | ||
foreach (var page in result.Pages) | ||
{ | ||
angle = page.ImageRotation; | ||
if (angle == 180) | ||
{ document.Pages[0].Rotation = PdfPageRotateAngle.RotateAngle90; } | ||
if (angle == 90) | ||
{ document.Pages[0].Rotation = PdfPageRotateAngle.RotateAngle270; } | ||
} | ||
} | ||
|
||
//Create file stream. | ||
using (FileStream outputFileStream = new FileStream("../../../Output.pdf", FileMode.Create, FileAccess.ReadWrite)) | ||
{ | ||
//Save the PDF document to file stream. | ||
document.Save(outputFileStream); | ||
} | ||
} |
Binary file added
BIN
+20.9 MB
...-image-rotation-angle-from-OCR/Get-image-rotation-angle-from-OCR/Tessdata/eng.traineddata
Binary file not shown.
Binary file added
BIN
+10.1 MB
...-image-rotation-angle-from-OCR/Get-image-rotation-angle-from-OCR/Tessdata/osd.traineddata
Binary file not shown.
Binary file added
BIN
+3.88 MB
...n-angle-from-OCR/Get-image-rotation-angle-from-OCR/TesseractBinaries/leptonica-1.80.0.dll
Binary file not shown.
Binary file added
BIN
+2.94 MB
...e-from-OCR/Get-image-rotation-angle-from-OCR/TesseractBinaries/libSyncfusionTesseract.dll
Binary file not shown.