We help IT Professionals succeed at work.
Get Started

PHP Class Problem with trying to execute pdftotext class

dogsareit asked
Last Modified: 2020-01-15
I have been struggling for 2 days on trying to resolve a problem and need help. I am using localhost, Win10 and Wampserver.
My goal is to use pdftotext class for php and composer. I have been trying to follow the instructions at URL:

Open in new window

The first problem was trying to install composer. I already have curl installed, PHP 5.6.25 installed but when I tried installing using their curl example :
# Install composer
curl -s http://getcomposer.org/installer | php
# Upgrade your install
php composer.phar install

Open in new window

it errored out.
So I installed Composer from the URL:

Open in new window

and selected 'developer' and from the cmd line, I executed composer -v. It appears to be installed correctly. (In my previous attempts, I used the option of everyone but thought better of it so I uninstalled it, reboot my computer and installed using developers mode.
The next step was to download the pdftotext.
I unzipped it to my project folder, made a folder ""php-xpdf/php-xpdf" and moved the contents of the bin32 to "php-xpdf/php-xpdf"
 folder in my project folder.
I noticed that the folders in the Vendor folder, log,monolog,php-console,psr all have a composer.json file.
This is URL for the xpdf:

Open in new window

My project path is:

Open in new window

My Vendor folder path is:

Open in new window

This is the original coding snippet recommended to me:
use Monolog\Logger;
use Monolog\Handler\NullHandler;
use XPDF\PdfToText;

// Create a logger
$logger = new Logger('MyLogger');
$logger->pushHandler(new NullHandler());

// You have to pass a Monolog logger
// This logger provides some usefull infos about what's happening
$pdfToText = PdfToText::load($logger);

// open PDF

// PDF text is now in the $text variable
$text = $pdfToText->getText();

Open in new window

And the composer.json:  (it's located at the root of my project - C:\wamp\www\PDFConvert)
    "require": {
        "monolog/monolog": "^1.25",
        "php-console/php-console": "^3.1"
	"php-xpdf/php-xpdf": "master"

Open in new window

I even preceded the previous locations with vendor/ and tried it.
I keep getting the same error:
 Class 'XPDF\PdfToText' not found in C:\wamp\www\PDFConvert\testpdf.php on line 16
See attached image.

I am thinking this is just a pathing problem and stupidity on my part - but I sure as heck can not seem to get it right no matter what I try.
Any help would be appreciated, Thank you
Watch Question
Most Valuable Expert 2020
Most Valuable Expert 2018
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE