christian-vigh-phpclasses / PdfToText

Extracts text from PDF files
Other
124 stars 92 forks source link

Error of 'Undefined Constant 'IMG_JPEG' #38

Open Pajservices opened 3 years ago

Pajservices commented 3 years ago

Hope someone can help with this. I'm trying to use this pdftotext class in a script that runs without a graphical interface - just to get some text out of a pdf. I'm running it just as a bat file. or command line and getting the error;

Use of undefined constant IMG_JPEG - assumed 'IMG_JPEG' and it's stopping my script.

Any ideas how i fix this.

Thanks in advance

arathra commented 3 years ago

Can I ask if you made any progress with this? We're having exactly the same problem

PHP Warning: Use of undefined constant IMG_JPEG - assumed 'IMG_JPEG' (this will throw an Error in a future version of PHP)

I'm sure it can't just be the 2 of us!

Pajservices commented 3 years ago

Hi Arathra- No sorry I didn't, and gave up on it.

I was trying to create forms in pdf for a client - then read the data out. I found PDFFiller instead and am using that. It will export the fields into an excel format for you.

Phil

arathra commented 3 years ago

Thanks for getting back to me, Phil. Shame about that; I guess that means we'll be looking for an alternative as well. We need to "read" users' PDF uploads so while PDFFiller isn't for us, I'm sure something out there will work.

All the best.

arathra commented 3 years ago

Hi Phil,

It took a bloody long time but I think I have solved it by using a different PDF converter here: https://github.com/smalot/pdfparser/ along with vendor/autoload.php

It works for me and doesn't produce any errors.

Cheers

Pajservices commented 3 years ago

That’s great news Christian, and thanks for letting me know.

I’ll have a look at that

Regards

Phil Jones

From: arathra notifications@github.com Sent: 29 October 2020 18:00 To: christian-vigh-phpclasses/PdfToText PdfToText@noreply.github.com Cc: Phil Jones phil@pajservices.co.uk; Author author@noreply.github.com Subject: Re: [christian-vigh-phpclasses/PdfToText] Error of 'Undefined Constant 'IMG_JPEG' (#38)

Hi Phil,

It took a bloody long time but I think I have solved it by using a different PDF converter here: https://github.com/smalot/pdfparser/ along with vendor/autoload.php

It works for me and doesn't produce any errors.

Cheers

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/christian-vigh-phpclasses/PdfToText/issues/38#issuecomment-718924226 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AGHHW6DH6GYENK37ZGKFZELSNGUQZANCNFSM4R5PKJAA . https://github.com/notifications/beacon/AGHHW6EH7EXR23SMP2O6UZLSNGUQZA5CNFSM4R5PKJAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFLM6TQQ.gif

niklaus133 commented 3 years ago

hi I think I have solved it you need to downgrade your php version to 7.4 the problem is in the version 8 of php

melvin-merchandisefabriek commented 2 months ago

I'm sure none of the people that asked this are in need of it anymore but for anyone else that still encounters this error, all you need to do is put the IMG_JPEG in quotes like the error is suggesting.

PHP Warning: Use of undefined constant IMG_JPEG - assumed 'IMG_JPEG' (this will throw an Error in a future version of PHP)

just go to the pdftotext class ctrl+f to find IMG_JPEG and change it to 'IMG_JPEG'