dyausp / html2pdf

Automatically exported from code.google.com/p/html2pdf
GNU Lesser General Public License v2.1
0 stars 0 forks source link

FPDF error: GIF parser: unable to open file .gif file. #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have some issue after using the html2pdf script. I am using php5 version
and i know that script is not compatible on php5 version, but know about
these things i try that script on php5 caught in issue. Issue is FPDF
error: GIF parser: unable to open file .gif file. Is there any way to to
run this script on php5. Please help us if it is possible..

Thanks.. 

Original issue reported on code.google.com by vickygo...@gmail.com on 18 Nov 2008 at 8:07

GoogleCodeExporter commented 9 years ago
I cam across the same issue and did some minor debugging.
I see that ord($data{0}) on load() function of CGIFIMAGE class returns 0x47 
resulting
in this message. 
I hope that gives some pointer. I am attempting to fix this myself. will update 
if I
come to something. Please mail me if a solution is found. 
Regards,
Shantanu Bhadoria

Original comment by shantanu.bhadoria on 7 Apr 2009 at 9:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
You can easily fix this issue by replacing the function _parsegif from fpdf 
version 
1.6. Here's the replacement code:

function _parsegif($file)
{
    //Extract info from a GIF file (via PNG conversion)
    if(!function_exists('imagepng'))
        $this->Error('GD extension is required for GIF support');
    if(!function_exists('imagecreatefromgif'))
        $this->Error('GD has no GIF read support');
    $im=imagecreatefromgif($file);
    if(!$im)
        $this->Error('Missing or incorrect image file: '.$file);
    imageinterlace($im,0);
    $tmp=tempnam('.','gif');
    if(!$tmp)
        $this->Error('Unable to create a temporary file');
    if(!imagepng($im,$tmp))
        $this->Error('Error while saving to temporary file');
    imagedestroy($im);
    $info=$this->_parsepng($tmp);
    unlink($tmp);
    return $info;
}

Original comment by jim.k...@gmail.com on 13 May 2009 at 6:44

GoogleCodeExporter commented 9 years ago
I had thought of this solution but this is a temporary solution and it involves
expensive file operations which we should rather avoid esp if we are creating a 
pdf
with lots of gif images. There should be a way to do this without the file 
operations.

Original comment by shantanu.bhadoria on 14 May 2009 at 5:45

GoogleCodeExporter commented 9 years ago
This can easily be fixed! PHP5 seems to have changed the order of assigning a 
value
to a variable when it is passed by reference.

I have attached my gif.php where I have done the needed changes.

There were some function calls by reference that got called like this:
$this->skipExt($data, $len = 0)

In PHP4, $len first got the value 0 and then the function will be called with a
reference to $len.

In PHP5, the function get's called with a reference to $len and THEN give it the
value 0 and overwrite the needed value...

Original comment by falco20019 on 14 Sep 2009 at 3:04

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks,  falco20019.
After replacing my gif.php with your version, my script works now.

Original comment by ismail.f...@gmail.com on 16 Dec 2009 at 4:32

GoogleCodeExporter commented 9 years ago
Am getting currupted code from zip, while i download it. Whoever can give me the
correct files. Thanks in advance.

Original comment by soorejgu...@gmail.com on 17 May 2010 at 12:01

GoogleCodeExporter commented 9 years ago
God bless you!!!!
After replacing my gif.php with your version, my script works perfectly!!
YAAAAAYEE!!!

Original comment by goo...@axemedia.com.au on 29 Oct 2010 at 12:32

GoogleCodeExporter commented 9 years ago
hi,

after replacing the gif.php file i am getting the following error

Fatal error: Call to a member function colorIndex() on a non-object in 
/home/premlobo/public_html/alia-clinic/web/pdf1/fpdf.php

plzzzzzz guide me...

Original comment by deepasa...@gmail.com on 16 Nov 2010 at 2:56

GoogleCodeExporter commented 9 years ago
Hi,

Why it doesn't support image files? Each time, it gives me no_img.gif. The 
location to my image is correct.

Original comment by adrianc....@gmail.com on 3 Apr 2011 at 10:24

GoogleCodeExporter commented 9 years ago
AWESOME even in 2011.  the file worked!!!! Thanks for the great share

Original comment by lisah...@gmail.com on 2 Nov 2011 at 7:49

GoogleCodeExporter commented 9 years ago
thanks falco...replacing that file did the trick

Original comment by pie...@solutech-systems.co.za on 20 Jun 2012 at 12:56