Coder Social home page Coder Social logo

qrcode's Introduction

mPDF QR code library

QR code generating library with HTML/PNG/mPDF output possibilities.

Build Status

This is based on QrCode library bundled with mPDF until v8.0, made by Laurent Minguet. It is provided under LGPL license.

Installation

$ composer require mpdf/qrcode

Usage

<?php

use Mpdf\QrCode\QrCode;
use Mpdf\QrCode\Output;

$qrCode = new QrCode('Lorem ipsum sit dolor');

// Save black on white PNG image 100 px wide to filename.png. Colors are RGB arrays.
$output = new Output\Png();
$data = $output->output($qrCode, 100, [255, 255, 255], [0, 0, 0]);
file_put_contents('filename.png', $data);

// Echo a SVG file, 100 px wide, black on white.
// Colors can be specified in SVG-compatible formats
$output = new Output\Svg();
echo $output->output($qrCode, 100, 'white', 'black');

// Echo an HTML table
$output = new Output\Html();
echo $output->output($qrCode);

qrcode's People

Contributors

finwe avatar fulldecent avatar gersonfs avatar kacercz avatar matthiaskuehneellerhold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

qrcode's Issues

why when u generate qrcode xml tag utf-8

I found this bug

This is mPDF and PHP version and environment (server/fpm/cli etc) I am using

This is the PHP code snippet I use

<?php


This is the HTML/CSS code snippet I use


Can't install

When I try to install this package, in Apache+PHP-FPM 7.4, I get the following error (BTW, I am using AWS SDK PHP inside my project):

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for mpdf/qrcode ^1.1 -> satisfiable by mpdf/qrcode[v1.1.0].
    - Conclusion: remove paragonie/random_compat v9.99.100
    - Conclusion: don't install paragonie/random_compat v9.99.100
    - mpdf/qrcode v1.1.0 requires paragonie/random_compat ^1.4|^2.0|9.99.99 -> satisfiable by paragonie/random_compat[v1.4.0, v1.4.1, v1.4.2, v1.4.3, v2.0.0, v2.0.1, v2.0.10, v2.0.11, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.2, v2.0.3, v2.0.4, v2.0.5, v2.0.6, v2.0.7, v2.0.8, v2.0.9, v9.99.99].
    - Can only install one of: paragonie/random_compat[v1.4.0, v9.99.100].
    - Can only install one of: paragonie/random_compat[v1.4.1, v9.99.100].
    - Can only install one of: paragonie/random_compat[v1.4.2, v9.99.100].
    - Can only install one of: paragonie/random_compat[v1.4.3, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.0, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.1, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.10, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.11, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.12, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.13, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.14, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.15, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.16, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.17, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.18, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.19, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.2, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.3, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.4, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.5, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.6, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.7, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.8, v9.99.100].
    - Can only install one of: paragonie/random_compat[v2.0.9, v9.99.100].
    - Can only install one of: paragonie/random_compat[v9.99.99, v9.99.100].
    - Installation request for paragonie/random_compat (locked at v9.99.100) -> satisfiable by paragonie/random_compat[v9.99.100].


Installation failed, reverting ./composer.json to its original content.

QR Code stripping multiple consecutive spaces from the entered code

I found this bug

Attempting to create a QR code with the value ETEX14 0001 (where there are 6 consecutive spaces) - the extra spaces are getting stripped and the resulting code is ETEX14 0001 - I have searched for where this is happening and not been able to find it or find any work-around. I have checked that I am able to read a QR code with the spaces correctly encoded by using a different tool to generate the QR code so I am reasonably sure the code is being "minified" somewhere in mPDF and excess spaces stripped out. I have not been able to find any option or configuration change that will stop this happening despite searching for several hours and attempting many configuration changes. I apologize if this is a configuration issue and not a bug, but I have not been able to get this working.

This is mPDF and PHP version and environment (server/fpm/cli etc) I am using

Using mpdf/mpdf V8.0.10, mpdf/qrcode V1.2.0 running under PHP 7.4 on Apache V2.4.41

This is the PHP code snippet I use

<?php

    // Require composer autoload - create $mpdf object
    require_once $_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';
    $mpdf = new \Mpdf\Mpdf([
        'format' => 'A4-P',
        'mode' => 'utf-8',
        'margin_left' => 0,
        'margin_right' => 0,
        'margin_top' => 0,
        'margin_bottom' => 0,
        'margin_header' => 0,
        'margin_footer' => 0,
        'nonPrintMargin' => 4
    ]);  //MPDF8

//Create HTML page in variable $html...(not shown)

$Location = 'EX14';
$BarcodeLocation = 'ET' . str_pad($Location, 10, " ", STR_PAD_RIGHT) . '0001';
$html .= "<barcode code=\"$BarcodeLocation\" type=\"QR\" class=\"barcode\" size=\"0.3\" error=\"M\" disableborder=\"1\" />\n";

//much later...
$mpdf->WriteHTML(trim($html),\Mpdf\HTMLParserMode::DEFAULT_MODE);
$mpdf->Output("Int_Doc_A4_Labels.pdf", "I");

This is the HTML/CSS code snippet I use

All is above...

Incorrect usage example in README.md file

This project seems unmaintained so I am posting bug report instead of PR for those who want still to use this library.


Example usage shown in project README.md is incorrect. The last argument passed to output() is NOT target file name but image compression level. It can be omitted for default value (or you can pass whatever imagepng() allows). The output() method returns PNG image so if you want to save it to the file, proper code looks like this (I also made it less compact or readability):

<?php

use Mpdf\QrCode\QrCode;
use Mpdf\QrCode\Output;

$qrCode = new QrCode('Lorem ipsum sit dolor');
$output = new Output\Png();

// Save black on white PNG image 100px wide to filename.png
$qrWidth = 100;
$bgColor = [255, 255, 255];
$fgColor = [0, 0, 0];
$qrImg = $output->output($qrCode, $qrWidth, $bgColor, $fgColor);
file_put_contents('filename.png', $qrImg);

How to save to filename.png?

The example will not work

// Save black on white PNG image 100px wide to filename.png
$output->output($qrCode, 100, [255, 255, 255], [0, 0, 0], 'filename.png');

The position for filename is in reality for int $compression

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.