AVAILABLE NOW: Spring 2025 Release

Convert Multi-page TIFF to Searchable PDF in C#, Java, and C

By Apryse | 2025 Apr 08

Sanity Image
Read time

6 min

Here’s a scenario that helps explain Apryse OCR functionality: It is tax season in the US. My CPA wants all of my supporting documentation to be saved as PDF, but I saved all as one multi-page TIFF when I scanned them. Fortunately, I have access to Apryse OCR. 

In terms of functionality and platform support, Apryse OCR is the most flexible OCR engine available. It makes converting more than 200 image types to PDF and other document formats an easy task. The resulting PDF can be an image-based or text-searchable PDF. It can even be a combination of image over text so the resulting PDF has the text, but looks exactly like the TIFF.

The following simplified C# code will convert any supported image format, including TIFF, to a text-searchable PDF file.

Convert TIFF to PDF in C#

Copied to clipboard

C# Code: 

static void OCR(string inputFile, string outputFile) { 

     bool use_iris = OCRModule.IsIRISModuleAvailable(); 

     try {  

         // A) Setup empty destination doc using PDFDoc doc = new PDFDoc(); 

   // B) Set English as the language of choice 
   OCROptions opts = new OCROptions(); 
   if (use_iris) opts.SetOCREngine("iris"); 
   opts.AddLang("eng"); 
 
   // C) Run OCR on the .tif with options             
   OCRModule.ImageToPDF(doc, inputFile, opts); 
 
   // D) check the result 
   doc.Save(outputFile, SDFDoc.SaveOptions.e_remove_unused);  

        }  catch (PDFNetException e) { Console.WriteLine(e.Message); }  

} 

Java Code:

Copied to clipboard

static void OCR(String inputFile, String outputFile) { 

                boolean use_iris = OCRModule.isIRISModuleAvailable(); 

                try (PDFDoc doc = new PDFDoc()) // A) Setup empty destination doc 

                { 

                    OCROptions options = new OCROptions(); 

                    if(use_iris) options.setOCREngine("iris"); 

 

                    // B) Run OCR on the .png with options 

                    OCRModule.imageToPDF(doc, input_path, options); 

 

                    // C) check the result 

                    doc.save(output_path, SDFDoc.SaveMode.LINEARIZED, null); 

                     

                } catch (Exception e) { 

                    e.printStackTrace(); 

                } 

            } 

 

C/CPP Code: 

static void OCR(string input_path, string output_path) { 

                try 

                { 

                    const bool use_iris = OCRModule::IsIRISModuleAvailable(); 

             

                    // A) Setup empty destination doc 

                    PDFDoc doc; 

             

                    // B) Run OCR on the .png without options 

                    OCROptions opts; 

                    if (use_iris) opts.SetOCREngine("iris"); 

                    OCRModule::ImageToPDF(doc, input_path, &opts); 

             

                    // C) check the result 

                    doc.Save(output_path, 0, 0); 

                } 

                catch (Common::Exception& e) 

                { 

                    cout << e << endl; 

                } 

                catch (...) 

                { 

                    cout << "Unknown Exception" << endl; 

                } 

            } 

It is just that easy. Further, Apryse is all you need to accomplish this task. No third-party software is needed.

Try the Apryse SDK for free. It’s fully-functional for 30 days and comes with free chat and email support.

Stay Tuned for More Conversion Samples

Stay tuned for more conversion examples to see how the Apryse document converter will easily fit into any workflow converting PDF files into other document files or images and back again. Need help in the meantime? Contact us. 

Sanity Image

Apryse

Share this post

email
linkedIn
twitter