簡體   English   中英

如何在MySQL數據庫中存儲Datamatrix QR碼?

[英]how to store Datamatrix QR code in mysql Database?

我想存儲數據矩陣庫使用php將QR碼圖像生成到mysql數據庫中。 我正在嘗試通過使用jpgraph庫。 請提供解決方案。

<?php
require_once('jpgraph/datamatrix/datamatrix.inc.php');

$data = '1234567890';

$shape       = DMAT_AUTO;
$encoding    = ENCODING_AUTO;
$modulewidth = 3;
$quietzone   = 10;
$color1      = 'black';
$color0      = 'white';
$colorq      = 'white';
$outputfile  = '';

// Create and set parameters for the encoder
$encoder = DatamatrixFactory::Create($shape);
$encoder->SetEncoding($encoding);

// Create the image backend (default)
$backend = DatamatrixBackendFactory::Create($encoder);

// By default the module width is 2 pixel so we increase it a bit
$backend->SetModuleWidth($modulewidth);

// Set Quiet zone
$backend->SetQuietZone($quietzone);

// Set other than default colors (one, zero, quiet zone/background)
$backend->SetColor($color1, $color0, $colorq);

// Create the barcode from the given data string and write to output file
try {
    $backend->Stroke($data,$outputfile);
} catch (Exception $e) {
    $errstr = $e->GetMessage();
    echo "Datamatrix error message: $errstr\n";
}
?>
    $data = '123456789';

    $pdf = new Pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetTitle('ECOMAL ');

    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

    $pdf->SetMargins(2,2,2);
    $pdf->SetHeaderMargin(0);
    $pdf->SetFooterMargin(0);

    $pdf->SetAutoPageBreak(TRUE, 0);

    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);


    if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
        require_once(dirname(__FILE__).'/lang/eng.php');
        $pdf->setLanguageArray($l);
    }

    $pdf->SetFont('helvetica', 'B', 18);

    $pdf->SetFont('helvetica', '', 15);

        $style = array(

          'fgcolor' => array(0,0,0),
          'bgcolor' => false, 

        );
    foreach ($data as  $value) {

     $tbl = '<table border="1" cellpadding="1">
        <tr><td>
            <table cellpadding="1" cellspacing="6" nobr="true">
                    <tr><td colspan="3"><h1> Vishy Intertechnology Inc.</h1></td></tr>
                    <tr><td colspan="3"><hr></td></tr>
                    <tr><td>Customer PN</td><td colspan="2" ><b>'. $value["customer_pin"].'</b></td></tr>
                    <tr><td>Customer PO</td><td colspan="2" ><b>'. $value["customer_po"] .'</b></td></tr>
                    <tr><td>Manfacture PN</td><td colspan="2" >'. $value["manufacture_pin"] .' </td></tr>
                    <tr><td>Quantity</td><td>'.$value["quantity"].'</td><td rowspan="4" width="35%"></td></tr>
                    <tr><td>Date Code</td><td>'.$value["date_of_code"] .'</td></tr>
                    <tr><td>Lot No</td><td>'.$value["lot_no"] .'</td></tr>
                    <tr><td>Serial No</td><td>'. $value["serial_no"].' </td></tr>
                    <tr><td>MSL</td><td>'.$value["msl"].'</td><td><br></td></tr>
            </table>
        </td></tr>
    </table><br><br>
    ';
        $pdf->AddPage('L','A6');
        //$pdf->SetY(50);

        $pdf->writeHTML($tbl, true, false, false, false, '');
        $pdf->write2DBarcode($value['code_string'], 'DATAMATRIX', 105, 48, 35, 35, $style, 'N');
    }
    //ob_clean();
    //Close and output PDF document
    //$rand = rand();
    $pdf->Output($_SERVER['DOCUMENT_ROOT']."/alcon/assets/ecomal.pdf", 'F');
    $pdf->Output("ecomal.pdf", 'I');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM