PHP Classes

minor issues with PHP version 5.2.4

Recommend this page to a friend!

      PHP PDF to Text  >  All threads  >  minor issues with PHP version 5.2.4  >  (Un) Subscribe thread alerts  
Subject:minor issues with PHP version 5.2.4
Summary:minor changes to the class to make it work
Messages:9
Author:Aryan Schmitz
Date:2016-12-14 11:02:31
 

  1. minor issues with PHP version 5.2.4   Reply   Report abuse  
Picture of Aryan Schmitz Aryan Schmitz - 2016-12-14 11:02:31
Hi Christian,

Running PdfToText version 1.3.7 on PHP version 5.2.4 I had PHP errors on line 2157 and on line 3995. After a small change it seems ok.

on line 2157 I changed:
if ( $current_font_size )
to
if ( $current_font_size > 0)

and on line 3995 I changed:
implements \ArrayAccess, \Countable
to
implements ArrayAccess, Countable

I don’t know if my fix for line 3995 does not break something but at least the class seems to work ok this way.

With best regards
Aryan

  2. Re: minor issues with PHP version 5.2.4   Reply   Report abuse  
Picture of Christian Vigh Christian Vigh - 2016-12-14 11:29:53 - In reply to message 1 from Aryan Schmitz
Hello Aryan,

many thanks for your reporting.

Regarding line 2157, I don't know what happens. It seems that the $current_font_size variable contains either a negative value or a non-numeric value. I update the source according to your change however, I would be curious to check if it does not come from a bug in my code located in another place. Would it be possible to send me a sample PDF file whose processing generates such an error ?

Regarding line 3995, my fault ; I have two versions of the PdfToText class, one which is integrated in my own framework, Thrak (https://github.com/christian-vigh/thrak) and one that I'm packing only to publish it as a standalone class on phpclasses.org. The notation "implements \someinterface" became usable starting from PHP 5.3 (or 5.2.x?). Before that, you could not indicate that the interface was located in the root namespace, and php was bailing when it encountered a leading backslash a class name (keyword "extends") or an interface name (keyword "implements").

During my last Winmerge session between my two versions of PdfToText, there were so many small modifications elsewhere in the code that I mistakenly validated this update. Will try to pay better attention next time !

With kind regards,
Christian.

  3. Re: minor issues with PHP version 5.2.4   Reply   Report abuse  
Picture of Aryan Schmitz Aryan Schmitz - 2016-12-14 12:13:22 - In reply to message 2 from Christian Vigh
Dear Christian,

Thank you for your prompt reply.

I think $current_font_size is 0 because I get
Warning: Division by zero in ………/PdfToText.phpclass on line 2158
without the $current_font_size>0

I get int(0)
when I put:
echo $current_font_size;
var_dump( $current_font_size);
right after
if ( $current_font_size )

I ‘ll send you the PDF file too :-)

Best regards
Aryan

  4. Re: minor issues with PHP version 5.2.4   Reply   Report abuse  
Picture of Christian Vigh Christian Vigh - 2016-12-14 12:44:36 - In reply to message 3 from Aryan Schmitz
Hello Aryan,

Thanks for the sample ! there was indeed a problem that was due to the fact that some font specifiers in your sample were using a dot in their name (eg, "/F1.0" where I expected "/F1_0"). This stupidly caused the current font size to be set to a dot instead of the number just after the specifier. Hence the division by zero.

I made a fix which will be available in version 1.3.8 ; meanwhile, you can keep the correction you made in version 1.3.7, it should not affect the output of the PdfToText class.

Christian.

  5. Re: minor issues with PHP version 5.2.4   Reply   Report abuse  
Picture of Aryan Schmitz Aryan Schmitz - 2016-12-14 13:44:52 - In reply to message 4 from Christian Vigh
Hello Christian,

Thank you. I had assumed differences in the way zero/null values are treated between PHP versions was causing this.

Glad my PDF file could help you finding the source of the issue :-)

/Aryan

  6. Re: minor issues with PHP version 5.2.4   Reply   Report abuse  
Picture of Aryan Schmitz Aryan Schmitz - 2016-12-27 14:07:49 - In reply to message 5 from Aryan Schmitz
Hello Christian,

Seems I’ve forgotten to mention that there also is/was another issue causing an fatal error on line 90.

I “fixed" it by replacing:
abstract class PdfObjectBase extends Object

with:
abstract class PdfObjectBase //extends Object

and the class seems to work without any issues but I’m not sure if that does not mess up anything else.

With season's greetings and best wishes for 2017!
Aryan

  7. Re: minor issues with PHP version 5.2.4   Reply   Report abuse  
Picture of Aryan Schmitz Aryan Schmitz - 2016-12-27 14:07:54 - In reply to message 5 from Aryan Schmitz
Hello Christian,

Seems I’ve forgotten to mention that there also is/was another issue causing an fatal error on line 90.

I “fixed" it by replacing:
abstract class PdfObjectBase extends Object

with:
abstract class PdfObjectBase //extends Object

and the class seems to work without any issues but I’m not sure if that does not mess up anything else.

With season's greetings and best wishes for 2017!
Aryan

  8. Re: minor issues with PHP version 5.2.4   Reply   Report abuse  
Picture of Christian Vigh Christian Vigh - 2016-12-27 19:30:00 - In reply to message 7 from Aryan Schmitz
Hello Aryan,

it seems you were unlucky : you downloaded the "first" version 1.3.8 that existed only for a few hours ; It contained two mods that should have remained in my framework, but I mistakenly reported them in the phpclasses version.

I've corrected that since them, so if you download the class again, everything should be ok.

  9. Re: minor issues with PHP version 5.2.4   Reply   Report abuse  
Picture of Aryan Schmitz Aryan Schmitz - 2016-12-27 21:25:30 - In reply to message 8 from Christian Vigh
Hello Christian,

Thank you and I can confirm that it worked when I downloaded the class again.

Best regards
Aryan