PHP Classes

Invalid argument supplied for foreach() (PHP version 5.2.4)

Recommend this page to a friend!

      PHP PDF to Text  >  All threads  >  Invalid argument supplied for...  >  (Un) Subscribe thread alerts  
Subject:Invalid argument supplied for...
Summary:Invalid argument warning
Messages:7
Author:Aryan Schmitz
Date:2016-11-05 19:25:04
 

  1. Invalid argument supplied for...   Reply   Report abuse  
Picture of Aryan Schmitz Aryan Schmitz - 2016-11-05 19:25:04
Thank you for the resent updates Christian!

This is probably just something with my version of PdfToText v 1.3.3 modified for PHP version 5.2.4 but I get this PHP warning:

Warning: Invalid argument supplied for foreach() in /PdfToText.phpclass on line 1174

My code before and including line 1174 is:
// Build the page catalog
$this -> Pages = array() ;
$this -> PageMap -> MapObjects ( $text ) ;

// Extract text from the collected text elements
foreach ( $this -> PageMap -> Pages as $page_number => $page_objects )
{
$this -> Pages [ $page_number ] = '' ;

foreach ( $page_objects as $page_object )

Other than this warning it converts a pdf a little different from 1.3.2 The strings of bogus that is not converted properly are still not converted correct but the bogus text is different.
For example in 1.3.2 some output lines of the could be like this:
ID xœ’
„/Lrq!k4|rhk€%‚ž"…Nrvi5—–”ν-#Q‹— K,`]b
VM 
Important Notices
Thank you for choosing Inform UPS Systems. This document provides all the instructions necessary for
the installation and the operation of the Saver DSP Uninterruptible Power Supply.


The latest version 1.3.3 converts the same lines to:
IID x����
� �/Lrq�!k����4|rhk��%���"�х�Nr���v�i�5����ν�-�#Qߋ�� K,`�]b
V�����M� ��
Important Notices
Thank you for choosing Inform UPS Systems. This document provides all the instructions necessary for
the installation and the operation of the Saver DSP Uninterruptible Power Supply.

If you like I can send you the PDF file that I used.

With best regards
Aryan

  2. Re: Invalid argument supplied for...   Reply   Report abuse  
Picture of Christian Vigh Christian Vigh - 2016-11-05 19:46:06 - In reply to message 1 from Aryan Schmitz
Hello Aryan,

yes, send me the pdf file you used, along with your custom version of PdfToText (in case of...).

It's curious : it seems that in the messy part, non 7-bit characters are replaced with 0xFD 0XFF (65533) and that 7-bit characters are preserved ; we find the same sequences "/Lrq" or "4|rhk".

All this confirm that your pdf file will definitely be highly welcome !

Christian.

  3. Re: Invalid argument supplied for...   Reply   Report abuse  
Picture of Aryan Schmitz Aryan Schmitz - 2016-11-11 12:56:25 - In reply to message 2 from Christian Vigh
Thank you Christian,

Version 1.3.4 solved the warning issue I had

Warning: Invalid argument supplied for foreach() in /PdfToText.phpclass on line 1174

with 1.3.2 and 1.3.3 and now just works out of the box with PHP version 5.2.4 :-)

Best regards

  4. Re: Invalid argument supplied for...   Reply   Report abuse  
Picture of Christian Vigh Christian Vigh - 2016-11-11 13:02:32 - In reply to message 3 from Aryan Schmitz
great ! so this means that you didn't have any modification to do to make in run on your system ?

  5. Re: Invalid argument supplied for...   Reply   Report abuse  
Picture of Aryan Schmitz Aryan Schmitz - 2016-11-11 14:07:22 - In reply to message 4 from Christian Vigh
Yes that is correct, I do not need to modify the class anymore, it now works just fine.

I (still) need to add <meta charset="utf-8" /> into <head></head> html tags of the php file where the class is called but that is just because the default character is not UTF in my case.

  6. Re: Invalid argument supplied for...   Reply   Report abuse  
Picture of Christian Vigh Christian Vigh - 2016-11-11 14:17:17 - In reply to message 5 from Aryan Schmitz
good point for the header ! I will add this in my documentation for future users and modify the examples accordingly.

Thanks for the information...
Christian.

  7. Re: Invalid argument supplied for...   Reply   Report abuse  
Picture of Aryan Schmitz Aryan Schmitz - 2016-11-11 14:55:45 - In reply to message 6 from Christian Vigh
Thank you for making this class better and better!

If you modify the examples you might also modify the sample.text files so that they are UTF encoded if they are not already. In my case I think they where latin-1 iso-8859-1? and presented incorrectly.

Best regards
Aryan