1

I am converting PDF file (contains unicodes, figures, equations of math, chamistry) to Image using Imagick tool.

$pdf = new Imagick();
$pdf->readimage($pdfFile);
$pdf->resetiterator();
$image = $pdf->appendimages(true);
$image->setimageformat(substr($destination, (strlen($destination) - 3), strlen($destination)));
$status = $image->writeimage($destination);

$image->clear();
$pdf->clear();

But now I need to search for specific string in the PDF file then split them and convert into image. Say this is a pdf document:

[integration]
//any integral equation
//another equation
[/integration]

[integration]
//some text and figures
[/integration]

Now I want to cut split the PDF file into two, starting at [integration] ending at [/integration]. And finally convert them into images. So the first image will contain:

//any integral equation
//another equation

And the second one:

//some text and figures

Any code/ideas please.

A. K. M. Tariqul Islam
  • 2,824
  • 6
  • 31
  • 48
  • Are these image file PDFs or text ones? If the former, then you're asking way more than you let on. – virmaior Dec 21 '13 at 08:16
  • Didn't get your answer. I mentioned that the PDF files contain more than just text, and image files will just contain the contents of the pdf file. – A. K. M. Tariqul Islam Dec 21 '13 at 08:25
  • [This](http://stackoverflow.com/questions/19414763/detect-and-alter-strings-in-pdfs/19551997#19551997) answer is an example of getting coordinates of text fragments. You rasterize entire page and then crop/split the image into as many images as [integration].. [/integration] pairs there are on the page. That'll work if text flows in single column, of course. – user2846289 Dec 21 '13 at 14:11
  • @CoolBrain, my question was confirming the nature of the PDF. PDFs can be either text + other things OR just images. If your PDFs are just images, then it would be rather difficult to implement what you want. – virmaior Dec 22 '13 at 00:05
  • @virmaior, sorry for my late. The nature of the PDF will be text+other things. Means, our flags will be in plain text. – A. K. M. Tariqul Islam Dec 23 '13 at 10:26

0 Answers0