mgufrone / pdf-to-html

PDF to HTML PHP Class using Poppler-Utils
MIT License
175 stars 88 forks source link

Spaces in PDF file names #16

Closed skilip closed 8 years ago

skilip commented 8 years ago

If a PDF filename contains spaces pdfinfo will not work. This can be easily fixed by applying the following patch:

diff --git a/vendor/gufy/pdftohtml-php/src/Pdf.php b/vendor/gufy/pdftohtml-php/src/Pdf.php
index 842690a..78d5768 100644
--- a/vendor/gufy/pdftohtml-php/src/Pdf.php
+++ b/vendor/gufy/pdftohtml-php/src/Pdf.php
@@ -19,7 +19,7 @@ class Pdf
   }
   protected function info()
   {
-    $content = shell_exec($this->bin().' '.$this->file);
+    $content = shell_exec($this->bin(). " '" .$this->file . "'");
     // print_r($info);
     $options = explode("\n", $content);
     $info = array();
skilip commented 8 years ago

The same applies for Base.php:

diff --git a/vendor/gufy/pdftohtml-php/src/Base.php b/vendor/gufy/pdftohtml-php/src/Base.php
index 57bb9d4..99d4344 100755
--- a/vendor/gufy/pdftohtml-php/src/Base.php
+++ b/vendor/gufy/pdftohtml-php/src/Base.php
@@ -49,7 +49,7 @@ class Base
                $this->setOutputDirectory(dirname($pdfFile));
                return $this;
        }
-       
+
        /**
        * generating html files using pdftohtml software.
        * @return $this current object
@@ -58,7 +58,7 @@ class Base
        {
                $output = $this->outputDir."/".preg_replace("/\.pdf$/","",basename($this->file)).".html";
                $options = $this->generateOptions();
-               $command = $this->bin()." ".$options." ".$this->file." ".$output;
+               $command = $this->bin()." ".$options." '".$this->file."' '".$output . "'";
                $result = exec($command);
                return $this;
        }
mgufrone commented 8 years ago

Hmmm, It looks good, how about you make a pull request to this repo? It would be nice.

mgufrone commented 8 years ago

I've pushed a new tag v2.0.7.

skilip commented 8 years ago

Thanks!