Skip to content
ComPDF

Convert PDF to Searchable PDF

Overview

To make a searchable PDF by adding invisible text to an image based PDF such as a scanned document using OCR.

Set Transparent Text Layer

When outputting a searchable PDF, you can use the following option to control the hidden text layer:

  • transparentText: Whether to output a transparent text layer.

Sample

The following example demonstrates how to convert a PDF document to a searchable PDF file.

php
use ComPDFKit\Conversion\OcrLanguage;

$option = new ConvertOption();
$option->enableOcr = true;
$option->languages = [OcrLanguage::ENGLISH];
$option->transparentText = true;

Conversion::convert('SearchablePdf', 'scan.pdf', 'password', 'output.pdf', $option);