Convert image to searchable PDF in PHP - rest7/api GitHub Wiki

This method creates a searchable PDF by converting image to text and then putting it together with original image in a PDF file. The method uses free API:

<?php
$url = 'http://server.com/image.png';
$data = json_decode(file_get_contents('http://api.rest7.com/v1/ocr.php?url=' . $url . '&format=pdf'));

if (@$data->success !== 1)
{
    die('Failed');
}
$pdf = file_get_contents($data->file);
file_put_contents('searchable.pdf', $pdf);