Skip to content

Commit a051df9

Browse files
committed
1003826: Added content for OCR Processor under features section
1 parent b77ef7a commit a051df9

8 files changed

Lines changed: 186 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Perform-OCR-on-Tiff-images/Perform-OCR-on-Tiff-images.csproj" />
3+
</Solution>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>
Binary file not shown.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{23E85557-733B-494C-8D01-816104E10267}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>Perform_OCR_on_Tiff_images</RootNamespace>
10+
<AssemblyName>Perform-OCR-on-Tiff-images</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
<NuGetPackageImportStamp>
16+
</NuGetPackageImportStamp>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<PlatformTarget>AnyCPU</PlatformTarget>
20+
<DebugSymbols>true</DebugSymbols>
21+
<DebugType>full</DebugType>
22+
<Optimize>false</Optimize>
23+
<OutputPath>bin\Debug\</OutputPath>
24+
<DefineConstants>DEBUG;TRACE</DefineConstants>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29+
<PlatformTarget>AnyCPU</PlatformTarget>
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="Syncfusion.Compression.Base, Version=32.1462.25.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
39+
<HintPath>..\packages\Syncfusion.Pdf.AspNet.Mvc5.32.1.25\lib\net462\Syncfusion.Compression.Base.dll</HintPath>
40+
</Reference>
41+
<Reference Include="Syncfusion.ImagePreProcessor.Base, Version=32.1462.25.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
42+
<HintPath>..\packages\Syncfusion.ImagePreProcessor.AspNet.Mvc5.32.1.25\lib\net462\Syncfusion.ImagePreProcessor.Base.dll</HintPath>
43+
</Reference>
44+
<Reference Include="Syncfusion.Licensing, Version=32.1462.25.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
45+
<HintPath>..\packages\Syncfusion.Pdf.AspNet.Mvc5.32.1.25\lib\net462\Syncfusion.Licensing.dll</HintPath>
46+
</Reference>
47+
<Reference Include="Syncfusion.OCRProcessor.Base, Version=32.1462.25.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
48+
<HintPath>..\packages\Syncfusion.Pdf.OCR.AspNet.Mvc5.32.1.25\lib\net462\Syncfusion.OCRProcessor.Base.dll</HintPath>
49+
</Reference>
50+
<Reference Include="Syncfusion.Pdf.Base, Version=32.1462.25.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
51+
<HintPath>..\packages\Syncfusion.Pdf.AspNet.Mvc5.32.1.25\lib\net462\Syncfusion.Pdf.Base.dll</HintPath>
52+
</Reference>
53+
<Reference Include="System" />
54+
<Reference Include="System.Core" />
55+
<Reference Include="System.Drawing" />
56+
<Reference Include="System.Xml.Linq" />
57+
<Reference Include="System.Data.DataSetExtensions" />
58+
<Reference Include="Microsoft.CSharp" />
59+
<Reference Include="System.Data" />
60+
<Reference Include="System.Net.Http" />
61+
<Reference Include="System.Xml" />
62+
</ItemGroup>
63+
<ItemGroup>
64+
<Compile Include="Program.cs" />
65+
<Compile Include="Properties\AssemblyInfo.cs" />
66+
</ItemGroup>
67+
<ItemGroup>
68+
<None Include="App.config" />
69+
<None Include="packages.config" />
70+
</ItemGroup>
71+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
72+
<Import Project="..\packages\Syncfusion.Pdf.OCR.AspNet.Mvc5.32.1.25\build\net462\Syncfusion.Pdf.OCR.AspNet.Mvc5.targets" Condition="Exists('..\packages\Syncfusion.Pdf.OCR.AspNet.Mvc5.32.1.25\build\net462\Syncfusion.Pdf.OCR.AspNet.Mvc5.targets')" />
73+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
74+
<PropertyGroup>
75+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
76+
</PropertyGroup>
77+
<Error Condition="!Exists('..\packages\Syncfusion.Pdf.OCR.AspNet.Mvc5.32.1.25\build\net462\Syncfusion.Pdf.OCR.AspNet.Mvc5.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Syncfusion.Pdf.OCR.AspNet.Mvc5.32.1.25\build\net462\Syncfusion.Pdf.OCR.AspNet.Mvc5.targets'))" />
78+
</Target>
79+
</Project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using Syncfusion.OCRProcessor;
2+
using System;
3+
using System.IO;
4+
using System.Text;
5+
using System.Drawing;
6+
using System.Drawing.Imaging;
7+
8+
namespace Perform_OCR_on_Tiff_images
9+
{
10+
internal class Program
11+
{
12+
static void Main(string[] args)
13+
{
14+
string filePath = "../../Input/multipage_tiff_example.tif";
15+
16+
var output = new StringBuilder();
17+
18+
using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
19+
using (var img = Image.FromStream(fs, useEmbeddedColorManagement: false, validateImageData: false))
20+
using (var processor = new OCRProcessor())
21+
{
22+
processor.TessDataPath = "../../TessdataBest/";
23+
processor.Settings.Language = Languages.English;
24+
processor.Settings.TesseractVersion = TesseractVersion.Version5_0;
25+
26+
// Determine how many frames/pages the TIFF contains.
27+
int frameCount = img.GetFrameCount(FrameDimension.Page);
28+
if (frameCount <= 1)
29+
{
30+
// Some TIFFs may use other dimensions; try Time/Resolution as fallback
31+
frameCount = Math.Max(frameCount, img.GetFrameCount(FrameDimension.Time));
32+
frameCount = Math.Max(frameCount, img.GetFrameCount(FrameDimension.Resolution));
33+
}
34+
if (frameCount < 1) frameCount = 1;
35+
36+
for (int i = 0; i < frameCount; i++)
37+
{
38+
// Prefer Page dimension
39+
try { img.SelectActiveFrame(FrameDimension.Page, i); }
40+
catch { /* fallback if needed */ }
41+
42+
// Clone the selected frame to a standalone Bitmap for OCR (important for some engines)
43+
using (var frameBmp = new Bitmap(img.Width, img.Height))
44+
using (var g = Graphics.FromImage(frameBmp))
45+
{
46+
g.DrawImage(img, 0, 0, img.Width, img.Height);
47+
48+
string pageText = processor.PerformOCR(frameBmp, processor.TessDataPath);
49+
output.AppendLine($"--- Page {i + 1} ---");
50+
output.AppendLine(pageText ?? string.Empty);
51+
output.AppendLine();
52+
}
53+
}
54+
}
55+
File.WriteAllText("Output.txt", output.ToString());
56+
57+
}
58+
}
59+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Perform-OCR-on-Tiff-images")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Perform-OCR-on-Tiff-images")]
13+
[assembly: AssemblyCopyright("Copyright © 2026")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("23e85557-733b-494c-8d01-816104e10267")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
[assembly: AssemblyVersion("1.0.0.0")]
33+
[assembly: AssemblyFileVersion("1.0.0.0")]
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Syncfusion.ImagePreProcessor.AspNet.Mvc5" version="32.1.25" targetFramework="net472" />
4+
<package id="Syncfusion.Pdf.AspNet.Mvc5" version="32.1.25" targetFramework="net472" />
5+
<package id="Syncfusion.Pdf.OCR.AspNet.Mvc5" version="32.1.25" targetFramework="net472" />
6+
</packages>

0 commit comments

Comments
 (0)