title: how to fix the error displayed by the PHP code?
body: <p>this question is the continues of this <a href="https://stackoverflow.com/questions/47694146/using-php-with-composer-did-not-find-the-required-class">last question with different error</a> 
  I've got a PHP code that selects a PDF file and converts it to a text file.</p>
  
  <p>I'm using an external library <strong>pdf-to-text</strong> with the composer.</p>
  
  <p>Following is the system display error:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught Spatie\PdfToText\Exceptions\CouldNotExtractText:
    The command "/usr/bin/pdftotext "pdf.pdf" -" failed. Exit Code:
    1(General error) Working directory: C:\xampp\htdocs\testcomposer
    Output: ================ Error Output: ================ The system
    cannot find the path specified. in
    C:\xampp\htdocs\testcomposer\src\Pdf.php:37 Stack trace: #0
    C:\xampp\htdocs\testcomposer\test2.php(8):
    Spatie\PdfToText\Pdf->text() #1 {main} thrown in
    C:\xampp\htdocs\testcomposer\src\Pdf.php on line 37</p>
  </blockquote>
  
  <h1>Project Structure :</h1>
  
  <ul>
  <li><p>testcomposer</p>
  
  <ul>
  <li><p>src</p>
  
  <pre><code>  -Exceptions
         -CouldNotExtractText.php
         -PdfNotFound.php
    -pdf.php
  </code></pre></li>
  <li><p>vendor</p>
  
  <pre><code>-composer
  -autoload.php
  </code></pre></li>
  <li><code>composer.json</code></li>
  <li><p><code>test2.php</code></p></li>
  <li><p><code>pdf.php</code></p></li>
  </ul></li>
  </ul>
  
  <h1>codes</h1>
  
  <h1>pdf.php</h1>
  
  <pre><code>&lt;?php
  
  namespace Spatie\pdftotext\src;
  
  use Spatie\pdftotext\src\Exceptions;
  use Symfony\process;
  
  class Pdf
  {
      protected $pdf;
  
      protected $binPath;
  
      public function __construct(string $binPath = null)
      {
          $this-&gt;binPath = $binPath ?? '/usr/bin/pdftotext';
      }
  
      public function setPdf(string $pdf) : Pdf
      {
          if (!file_exists($pdf)) {
              throw new PdfNotFound("could not find pdf {$pdf}");
          }
  
          $this-&gt;pdf = $pdf;
  
          return $this;
      }
  
      public function text() : string
      {
          $process = new Process("{$this-&gt;binPath} " . escapeshellarg($this-&gt;pdf) . " -");
          $process-&gt;run();
  
          if (!$process-&gt;isSuccessful()) {
              throw new CouldNotExtractText($process);
          }
  
          return trim($process-&gt;getOutput(), " \t\n\r\0\x0B\x0C");
      }
  
      public static function getText(string $pdf, string $binPath = null) : string
      {
          return (new static($binPath))
              -&gt;setPdf($pdf)
              -&gt;text();
      }
  }
  </code></pre>
  
  <h1>composer.json</h1>
  
  <pre><code>{
      "name": "spatie/pdf-to-text",
      "description": "Extract text from a pdf",
      "keywords": [
          "spatie",
          "pdftotext"
      ],
      "homepage": "https://github.com/spatie/pdf-to-text",
      "license": "MIT",
      "authors": [
          {
              "name": "Freek Van der Herten",
              "email": "freek@spatie.be",
              "homepage": "https://spatie.be",
              "role": "Developer"
          }
      ],
      "require": {
          "php" : "^7.0",
          "symfony/process": "^3.0"
      },
      "require-dev": {
          "phpunit/phpunit" : "^6.4"
      },
      "autoload": {
          "psr-4": {
              "src\\": "app/Spatie/pdftotext/src"
          }
      },
      "autoload-dev": {
          "psr-4": {
              "Spatie\\pdftotext\\Test\\": "tests"
          }
      },
      "scripts": {
          "test": "phpunit"
      }
  }
  </code></pre>
  
  <h1>test2.php</h1>
  
  <pre><code>    &lt;?php
  require 'vendor/autoload.php';
  
  use Spatie\PdfToText\Pdf;
  
  $text = (new Pdf())
      -&gt;setPdf('pdf.pdf')
      -&gt;text();
  
  print_r($text);
  ?&gt;
  </code></pre>