troubleshooting Question

PHP Class Problem with trying to execute pdftotext class

Avatar of dogsareit
dogsareitFlag for United States of America asked on
PHP
7 Comments1 Solution103 ViewsLast Modified:
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:
https://php-xpdf.readthedocs.io/en/latest/
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
it errored out.
So I installed Composer from the URL:
https://getcomposer.org/doc/00-intro.md
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:
http://www.xpdfreader.com/download.html

My project path is:
c:\wamp\www\PDFConvert
My Vendor folder path is:
c:\wamp\www\PDFConvert\Vendor

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
$pdfToText->open('PDF-book.pdf');

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

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"
    }
}
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
Class-XPDFPdfToText-Error.png
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros