-1

I'm trying to convert a pdf on my local computer to a jpg file and then using Tesseract to read the image text. Simply testing code like this:

    $pdf = new Pdf('C:\testing\test.pdf');
    $pdf->saveImage('C:\testing\test.jpg');
    $tess = new TesseractOCR('C:\testing\test.jpg');
    $myresults = $tess->run();
    $this->vars['result'] = $myresults;

Produces the following error: PDFDelegateFailed `The system cannot find the file specified. ' @ error/pdf.c/ReadPDFImage/794

I am using the following for my scenario:

OctoberCMS/Laravel

PHP 7.2.34 64 bit

Ghostscript 9.53.3 64 bit (32 bit didn't work either)

ImageMagick 7.0.7-11 Q16 x64

Xampp

Windows 10 64 bit

When I try converting a jpg to a png, ImageMagick works fine, but as soon as I try a PDF, I get the error. I have looked and tried solutions with little luck. I know the issue is most likely Ghostscript, as many have reported that it's the one that gives the most headaches on Windows 10, but I have no idea where to even begin trying to connect it to ImageMagick.

Any help, please?

BabulaNo
  • 23
  • 5
  • asked before: (without PHP) https://stackoverflow.com/questions/6605006/convert-pdf-to-image-with-high-resolution, (with PHP) https://stackoverflow.com/questions/9227014/convert-pdf-to-jpeg-with-php-and-imagemagick – Luuk Nov 17 '20 at 07:14
  • Does this answer your question? [Convert PDF to JPEG with PHP and ImageMagick](https://stackoverflow.com/questions/9227014/convert-pdf-to-jpeg-with-php-and-imagemagick) – Luuk Nov 17 '20 at 07:14
  • @Luuk thanks but it's the same result, I'm afraid. I have checked both questions in my quest for a viable solution. None working so far. – BabulaNo Nov 17 '20 at 08:40
  • Assuming you have GS installed with ImageMagick, see https://stackoverflow.com/questions/52861946/imagemagick-not-authorized-to-convert-pdf-to-an-image/52863413#52863413. You may also need to edit the ImageMagick delegates.xml file and put the full path to gs. – fmw42 Nov 17 '20 at 16:30

1 Answers1

0

Well, I did end up finding a workaround for this. Instead of using ImageMagick with Ghostscript, I ended up just using Ghostscript on its own. The conversion works flawlessly without issues.

BabulaNo
  • 23
  • 5