Git Product home page Git Product logo

Comments (5)

JanSlabon avatar JanSlabon commented on August 31, 2024

Can you share the PDF in question? We normally already have a fallback implemented:

$fh = fopen('php://temp', 'w+b');
fwrite($fh, "\x1f\x8b\x08\x00\x00\x00\x00\x00" . $oData);
stream_filter_append($fh, 'zlib.inflate', STREAM_FILTER_READ, ['window' => 30]);
fseek($fh, 0);
$data = @stream_get_contents($fh);
fclose($fh);

from fpdi.

zumoberhaus avatar zumoberhaus commented on August 31, 2024

With this PDF for example it was not working for me.
https://dev.data-infrasens.ch/uploads/directaccess?token=52ec7d4a34669bb51c58c565acdaa18c5c73e8f3

from fpdi.

JanSlabon avatar JanSlabon commented on August 31, 2024

The file works without a problem and already the fallback I quoted before is used. I isolated the logic to this and all PHP versions work there, too.

What PHP version are you using? And what is the zlib version that is used? (see phpinfo() output).

from fpdi.

zumoberhaus avatar zumoberhaus commented on August 31, 2024

PHP 8.0.26
zlib 1.2.7

I think, I have found a possible problem for me.
You supress the errors with "@" before the gzuncompress and then the fallback will raised.

I have a custom Error Handler implemented, which prints the warning "Warning: gzuncompress(): data error" anyway.
So my script fails, because of this output there.

Think this solves the problem for me.

from fpdi.

JanSlabon avatar JanSlabon commented on August 31, 2024

Ok, so you simply need to adjust your error handler to take care of the current error level:

function myErrorHandler($errno, $errstr, $errfile, $errline)
{
    if (!(error_reporting() & $errno)) {
        // This error code is not included in error_reporting, so let it fall
        // through to the standard PHP error handler
        return false;
    }
...

from fpdi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.