Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Perform-OCR-on-Tiff-images/Perform-OCR-on-Tiff-images.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{23E85557-733B-494C-8D01-816104E10267}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Perform_OCR_on_Tiff_images</RootNamespace>
<AssemblyName>Perform-OCR-on-Tiff-images</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Syncfusion.Compression.Base, Version=32.1462.25.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Pdf.AspNet.Mvc5.32.1.25\lib\net462\Syncfusion.Compression.Base.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.ImagePreProcessor.Base, Version=32.1462.25.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.ImagePreProcessor.AspNet.Mvc5.32.1.25\lib\net462\Syncfusion.ImagePreProcessor.Base.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.Licensing, Version=32.1462.25.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Pdf.AspNet.Mvc5.32.1.25\lib\net462\Syncfusion.Licensing.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.OCRProcessor.Base, Version=32.1462.25.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Pdf.OCR.AspNet.Mvc5.32.1.25\lib\net462\Syncfusion.OCRProcessor.Base.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.Pdf.Base, Version=32.1462.25.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Pdf.AspNet.Mvc5.32.1.25\lib\net462\Syncfusion.Pdf.Base.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<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')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<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>
</PropertyGroup>
<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'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Syncfusion.OCRProcessor;
using System;
using System.IO;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;

namespace Perform_OCR_on_Tiff_images
{
internal class Program
{
static void Main(string[] args)
{
string filePath = Path.GetFullPath(@"Data/multipage_tiff_example.tif");

StringBuilder output = new StringBuilder();

using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (Image img = Image.FromStream(fs, useEmbeddedColorManagement: false, validateImageData: false))
using (OCRProcessor processor = new OCRProcessor())
{
processor.TessDataPath = Path.GetFullPath(@"TessdataBest/");
processor.Settings.Language = Languages.English;
processor.Settings.TesseractVersion = TesseractVersion.Version5_0;

// Determine how many frames/pages the TIFF contains.
int frameCount = img.GetFrameCount(FrameDimension.Page);
if (frameCount <= 1)
{
// Some TIFFs may use other dimensions; try Time/Resolution as fallback
frameCount = Math.Max(frameCount, img.GetFrameCount(FrameDimension.Time));
frameCount = Math.Max(frameCount, img.GetFrameCount(FrameDimension.Resolution));
}
if (frameCount < 1) frameCount = 1;

for (int i = 0; i < frameCount; i++)
{
// Prefer Page dimension
try { img.SelectActiveFrame(FrameDimension.Page, i); }
catch { /* fallback if needed */ }

// Clone the selected frame to a standalone Bitmap for OCR (important for some engines)
using (Bitmap frameBmp = new Bitmap(img.Width, img.Height))
using (Graphics g = Graphics.FromImage(frameBmp))
{
g.DrawImage(img, 0, 0, img.Width, img.Height);

string pageText = processor.PerformOCR(frameBmp, processor.TessDataPath);
output.AppendLine($"--- Page {i + 1} ---");
output.AppendLine(pageText ?? string.Empty);
output.AppendLine();
}
}
}
File.WriteAllText(Path.GetFullPath(@"Output/Output.txt"), output.ToString());

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Perform-OCR-on-Tiff-images")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Perform-OCR-on-Tiff-images")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("23e85557-733b-494c-8d01-816104e10267")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Syncfusion.ImagePreProcessor.AspNet.Mvc5" version="32.1.25" targetFramework="net472" />
<package id="Syncfusion.Pdf.AspNet.Mvc5" version="32.1.25" targetFramework="net472" />
<package id="Syncfusion.Pdf.OCR.AspNet.Mvc5" version="32.1.25" targetFramework="net472" />
</packages>
Loading