Problem when generating file with images

Help
grbillo
2011-05-31
2012-10-09
  • grbillo
    grbillo
    2011-05-31

    Hi,
    I’m using TCPDF to generate pdf using mainly MultiCell and Image methods. It
    works perfectly excepted sometime when PDF contains large number of images. I
    get then the following PDF message: File doesn’t start by ‘%PDF-‘. If I remove
    one or more image, PDF is correctly generated.
    I have turned around this problem for a while and haven’t been able to fix it.
    Any idea ?
    Thanks for your help.

     
  • Nicola Asuni
    Nicola Asuni
    2011-05-31

    Are you using the latest TCPDF version?
    Can you provide a very simple script to reproduce the problem using (for
    example) a for loop and a default image?

     
  • grbillo
    grbillo
    2011-07-21

    Hi,

    I'm back after a while...

    Yes,nicolaasuni, I use the very latest TCPDF version and it's the same...

    I didn't done any progress on the problem itself but I found something that
    may help:
    - when I save the file to disk first and then open it with Reader it works fine
    - when I send the file inline to browser the problem occurs and I get the PDF error message: File does not begin with '%PDF-‘.

    Maybe this could help someone to get an idea.

    Thanks for your help.

     
  • tcpdf_5_9_172_php4.zip
    TCPDF File does not begin with '%PDF-'. ;(((

     
  • tcpdf_5_9_172_php4.zip

    In browser don't opened: TCPDF File does not begin with '%PDF-'. ;(((
    but Saved as .pdf, but don't open it with Reader !;((

    hey anybody - where rakes???;((

     
  • Nicola Asuni
    Nicola Asuni
    2012-07-28

    you are probably triggering some PHP error.
    Try to open the generated PDF file with an hex editor and read it, probably
    you will notice a PHP error inside.

     
  • ok:

    <br />
    <b>Warning</b>:  curl_setopt() [<a href='function.curl-setopt'>function.curl-setopt</a>]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in <b>/public_html/libraries/tcpdf/tcpdf.php</b> on line <b>7797</b><br />
    <br />
    <b>Warning</b>:  curl_setopt() [<a href='function.curl-setopt'>function.curl-setopt</a>]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in <b>/public_html/libraries/tcpdf/tcpdf.php</b> on line <b>7797</b><br />
    <br />
    <b>Warning</b>:  curl_setopt() [<a href='function.curl-setopt'>function.curl-setopt</a>]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in <b>/public_html/libraries/tcpdf/tcpdf.php</b> on line <b>7797</b><br />
    <br />
    <b>Warning</b>:  curl_setopt() [<a href='function.curl-setopt'>function.curl-setopt</a>]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in <b>/public_html/libraries/tcpdf/tcpdf.php</b> on line <b>7797</b><br />
    <br />
    <b>Warning</b>:  curl_setopt() [<a href='function.curl-setopt'>function.curl-setopt</a>]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in <b>/public_html/libraries/tcpdf/tcpdf.php</b> on line <b>7797</b><br />
    <br />
    <b>Warning</b>:  curl_setopt() [<a href='function.curl-setopt'>function.curl-setopt</a>]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in <b>/public_html/libraries/tcpdf/tcpdf.php</b> on line <b>7797</b><br />
    <br />
    <b>Warning</b>:  curl_setopt() [<a href='function.curl-setopt'>function.curl-setopt</a>]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in <b>/public_html/libraries/tcpdf/tcpdf.php</b> on line <b>7797</b><br />
    <br />
    <b>Warning</b>:  curl_setopt() [<a href='function.curl-setopt'>function.curl-setopt</a>]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in <b>/public_html/libraries/tcpdf/tcpdf.php</b> on line <b>7797</b><br />
    <br />
    <b>Warning</b>:  curl_setopt() [<a href='function.curl-setopt'>function.curl-setopt</a>]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in <b>/public_html/libraries/tcpdf/tcpdf.php</b> on line <b>7797</b><br />
    <br />
    <b>Warning</b>:  curl_setopt() [<a href='function.curl-setopt'>function.curl-setopt</a>]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in <b>/public_html/libraries/tcpdf/tcpdf.php</b> on line <b>7797</b><br />
    %PDF-1.7
    %вгПУ
    49 0 obj
    << /Type /Page /Parent 1 0 R /LastModified (D:20120728143217-04'00') /Resources 2 0 R /MediaBox [0.000000 0.000000 595.276000 841.890000] /CropBox [0.000000 0.000000 595.276000 841.890000] /BleedBox [0.000000 0.000000 595.276000 841.890000] /TrimBox [0.000000 0.000000 595.276000 841.890000] /ArtBox [0.000000 0.000000 595.276000 841.890000] /Contents 50 0 R /Rotate 0 /Group << /Type /Group /S /Transparency /CS /DeviceRGB >> /Annots [ 9 0 R 10 0 R 11 0 R 12 0 R 13 0 R 14 0 R 15 0 R 16 0 R 17 0 R 18 0 R 19 0 R 20 0 R 22 0 R 23 0 R ] /PZ 1 >>
    endobj
    50 0 obj
    <</Filter /FlateDecode /Length 6210>> stream
    
     
  • safe_mode Off !!!

     
  • for patch this bug set line 7797 to this value:

    curl_setopt($cs, CURLOPT_FOLLOWLOCATION, 0);
    
     
  • Nicola Asuni
    Nicola Asuni
    2012-07-29

    Seems that you are using an old TCPDF version, please upgrade.

     
  • yes - this bug to fix it in tcpdf_5_9_176_php4 version

    Thanks for support!