TIFF to Searchable PDF Converter
The IronTesseract
C# OCR class can automatically convert TIFF to searchable PDF. Below is an example of how you can achieve this functionality using IronTesseract
. We will first ensure that the necessary library is imported and initialized correctly, and then utilize it to perform the conversion.
// Import necessary libraries
using IronOcr;
namespace TiffToPdfConversion
{
class Program
{
static void Main(string[] args)
{
// Initialize the IronTesseract engine
var Ocr = new IronTesseract();
// Specify the file path of the TIFF file
var inputFilePath = @"path\to\your\image.tiff";
// Specify the path where the PDF should be saved
var outputFilePath = @"path\to\your\output.pdf";
// This command will read the TIFF file and convert it into a searchable PDF
using (var Input = new OcrInput(inputFilePath))
{
// Converts TIFF to PDF with OCR to make the PDF text searchable
Ocr.Read(Input).SaveAsPdf(outputFilePath);
}
// Inform the user that the process is complete
Console.WriteLine("The TIFF file has been successfully converted to a searchable PDF.");
}
}
}
// Import necessary libraries
using IronOcr;
namespace TiffToPdfConversion
{
class Program
{
static void Main(string[] args)
{
// Initialize the IronTesseract engine
var Ocr = new IronTesseract();
// Specify the file path of the TIFF file
var inputFilePath = @"path\to\your\image.tiff";
// Specify the path where the PDF should be saved
var outputFilePath = @"path\to\your\output.pdf";
// This command will read the TIFF file and convert it into a searchable PDF
using (var Input = new OcrInput(inputFilePath))
{
// Converts TIFF to PDF with OCR to make the PDF text searchable
Ocr.Read(Input).SaveAsPdf(outputFilePath);
}
// Inform the user that the process is complete
Console.WriteLine("The TIFF file has been successfully converted to a searchable PDF.");
}
}
}
' Import necessary libraries
Imports IronOcr
Namespace TiffToPdfConversion
Friend Class Program
Shared Sub Main(ByVal args() As String)
' Initialize the IronTesseract engine
Dim Ocr = New IronTesseract()
' Specify the file path of the TIFF file
Dim inputFilePath = "path\to\your\image.tiff"
' Specify the path where the PDF should be saved
Dim outputFilePath = "path\to\your\output.pdf"
' This command will read the TIFF file and convert it into a searchable PDF
Using Input = New OcrInput(inputFilePath)
' Converts TIFF to PDF with OCR to make the PDF text searchable
Ocr.Read(Input).SaveAsPdf(outputFilePath)
End Using
' Inform the user that the process is complete
Console.WriteLine("The TIFF file has been successfully converted to a searchable PDF.")
End Sub
End Class
End Namespace
Explanation:
- This C# code utilizes the
IronTesseract
library, part of IronOCR, to perform an OCR (Optical Character Recognition) operation. - The
OcrInput
instance is created to handle the input TIFF file, which is specified byinputFilePath
. - The
Read
method of theIronTesseract
instance is used to perform OCR on the input file. - Finally,
SaveAsPdf(outputFilePath)
is called to save the OCR result as a searchable PDF to the specified output location.
Make sure you have the IronOCR library installed and properly configured in your project to ensure the above code executes successfully.