Creating 'Searchabe PDF Images' from OCR-ed 'hidden' text and scanned TIFFs.


We perform the OCR on the TIFF file with third party software. It just
comes out as text file.

Can you please send me a sample code to merge images as sarchable PDF
document? It this possible?


Besides OCR text output you would also need to know the positioning
information for each word. This is important so that text highlighting
works as expected. Using this information you can add hidden text to
existing PDF images using ElementBuilder and ElemenWriter API along
the following lines:

  PDFDoc doc = new PDFDoc("my.pdf");

  ElementBuilder eb = new ElementBuilder();
  ElementWriter writer = new ElementWriter();

  Page page = doc.PageBegin().Current(); // Get the first page
  writer.Begin(page); // Begin writing to the page

  // Begin writing a block of text
  Element element = eb.CreateTextBegin(
       Font.StandardType1Font.e_times_roman), 12);

  string txt = "Hello World!";
  element = eb.CreateTextRun(txt);

  // Set text positioning matrix...
  // Scale-up text 5 times and shift it by (0,600)
  element.SetTextMatrix(5, 0, 0, 5, 0, 600);

  // In order to make invisible text that can be highlighted or
  // you need to set TextRenderingMode flag in the graphics state of
  // text element.
  GState gstate = element.GetGState();

  // During testing/debugging you may want to comment-out the following

  // Finish the block of text

  doc.Save("out.pdf", 0);
catch (PDFNetException e) {

The above sample code adds some hidden text to an existing PDF
documents. Using PDFNet you can also dynamically create PDF document
from existing image/TIFF files as illustrated in AddImage sample
project (

For more examples of how to add new page content, please see
ElementBuilder sample project (