christian-vigh-phpclasses / PdfToText

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

Potential Syntax Error causing white page of death when trying to run #2

Closed blainehilton closed 8 years ago

blainehilton commented 8 years ago

I have just downloaded your code and tried to run it and I was receiving a white page.

So I tried to use one of your examples (Example 1) and I received the same white page.

So then I tried running php -l example.php and it reported everything was fine.

However when I ran php example.php then I received the following:

PHP Parse error: syntax error, unexpected '[' in /x/lib/PdfToText-master/PdfToText.phpclass on line 343

When I look at the code initially I'm not seeing anything that looks amiss though.

I'm wondering could it be something with my environment? Is there some minimal version requirement or something? Are there any required PHP modules ?

Thanks in advance this looks like it could really be awesome to work with.

christian-vigh-phpclasses commented 8 years ago

Hi,

Well, to tell the truth, there is a minimal php version requirement : 5.5. I am using the new array notation, so line #343 looks like this :

        public   $Pages            =  [] ;

instead of :

        public  $Pages             =  array ( ) ;

This notation has been normally introduced into PHP 5.4.23, but some time ago, a phpclasses user reported me that it did not work with his version, PHP 5.4.37.

However, it works with all versions >= 5.5.

So as a conclusion, it has nothing to do with your own environment, except for your current php version (the PdfToText class does not require any external php module).

That should normally be the only prerequisite. Please note however that, regarding the examples :

1) You will be able to catch more results if you run them in CLI mode (especially messages of type NOTICE)

2) Currently, phpclasses.org does not allow to import pdf files. Unfortunately, all my examples use sample pdf files, which could not be imported, so the examples will not work, unless you provide your own sample.pdf file of your choice.

If you have the possibility to install a standalone php version on your personal system, you should be able to perform further tests.

Although the current PdfToText class works better that Adobe Acrobat « save to text » option, please note that there are still some issues with text decoding and page location. I am currently working on samples that some phpclasses users submitted to me, which are improperly decoded, so the current version of this class is highly susceptible to evolve. But don’t be afraid ! only the internals will be modified, the external api will remain the same…

I would be really happy if you could run at least some examples using this class, so please feel free to harass me if you encounter further problems !

With kind regards,

Christian Vigh.


De : blainehilton [mailto:notifications@github.com] Envoyé : jeudi 26 mai 2016 21:25 À : christian-vigh-phpclasses/PdfToText Objet : [christian-vigh-phpclasses/PdfToText] Potential Syntax Error causing white page of death when trying to run (#2)

I have just downloaded your code and tried to run it and I was receiving a white page.

So I tried to use one of your examples (Example 1) and I received the same white page.

So then I tried running php -l example.php and it reported everything was fine.

However when I ran php example.php then I received the following:

PHP Parse error: syntax error, unexpected '[' in /x/lib/PdfToText-master/PdfToText.phpclass on line 343

When I look at the code initially I'm not seeing anything that looks amiss though.

I'm wondering could it be something with my environment? Is there some minimal version requirement or something? Are there any required PHP modules ?

Thanks in advance this looks like it could really be awesome to work with.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it https://github.com/christian-vigh-phpclasses/PdfToText/issues/2 on GitHub https://github.com/notifications/beacon/ARM8avE0oek5vXl0dEiip_B13cImpmOSks5 qFfOdgaJpZM4In3pH.gif


L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus

blainehilton commented 8 years ago

Thank you for your work on doing this and your detailed response. I have installed PHP 5.5 and used my own PDF and it worked as expected so far in an initial test.