Coder Social home page Coder Social logo

Comments (4)

RebeccaRGB avatar RebeccaRGB commented on August 20, 2024

You also have to set the mime type in the header:

header('Content-Type: image/png');

from barcode.

hiorti avatar hiorti commented on August 20, 2024

@RebeccaRGB Thanks for the comment. However, I tried that and it didn't help. I tried the mime type in the header inside the php code, as well as inside the header template page where all the page headers are generated.

I am temporarily using the output from direct GET barcode.php results, using this line:

echo '<img style="display: inline;-webkit-user-select: none;margin: auto;background-color: hsl(0, 0%, 90%);transition: background-color 300ms;" src="https://.....com/barcode.php?f=png&amp;s=upc-a&amp;d=' . $products_upc . '">';

And even though that works fine, I am curious to find out the reason it doesn't work using

$image = $generator->render_image($symbology, $data, $options);
imagepng($image);
imagedestroy($image);

I use it inside a php generated page, where I am trying to show the product barcode along with the remaining product details.

Thanks again.

from barcode.

RebeccaRGB avatar RebeccaRGB commented on August 20, 2024

You can't just spit out a PNG directly in the middle of an HTML file. It does not work that way.

Using the img tag with barcode.php in the URL is the correct way to do what you're trying to do.

from barcode.

hiorti avatar hiorti commented on August 20, 2024

@RebeccaRGB Thanks for the update. So that is the issue. I will use the image tag then. Thanks again.

from barcode.

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.