PHP TCPDF バーコードとQRコード印刷

TCPDFでバーコードとQRコード印刷
本家のTCPDFのEXAMPLES に事例がいくつも掲載されている
https://tcpdf.org/examples/

あくまでも参考用に

//バーコードの印字

//write1DBarcode( $code, $type, $x, $y, $w, $h, $xres, $style, $align )
// define barcode style
$style = array(
‘position’ => ”,
‘align’ => ‘C’,
‘stretch’ => false,
‘fitwidth’ => true,
‘cellfitalign’ => ”,
‘border’ => false,
‘hpadding’ => ‘auto’,
‘vpadding’ => ‘auto’,
‘fgcolor’ => array(0,0,0),
‘bgcolor’ => false, //array(255,255,255),
‘text’ => false,
‘font’ => ‘helvetica’,
‘fontsize’ => 8,
‘stretchtext’ => 4
);
$pdf->SetFont(‘helvetica’, ”, 10);
//$pdf->Cell(0, 0, ‘CODABAR’, 0, 1);
//$pdf->write1DBarcode(‘123456789’, ‘CODABAR’, ”, ”, ”, 18, 0.4, $style, ‘N’);
$pdf->write1DBarcode(‘a2020082400073349a’, ‘CODABAR’, 201.75, 454, 34*1.75, 14, 0.2, $style, ‘N’);
//$pdf->Ln();

//QRコードの印字
$pdf->SetFont(‘helvetica’, ”, 10);

// – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

// set style for barcode
$style = array(
‘border’ => false,
‘vpadding’ => ‘auto’,
‘hpadding’ => ‘auto’,
‘fgcolor’ => array(0,0,0),
‘bgcolor’ => false, //array(255,255,255)
‘module_width’ => 1, // width of a single module in points
‘module_height’ => 1 // height of a single module in points
);

// write RAW 2D Barcode

//write2DBarcode( $code, $type, $x, $y, $w, $h, $style, $align, $distort )
$code = ‘2020082400073349’;
//$pdf->write2DBarcode($code, ‘QRCODE,Q’, 601.75, 454, 30, 20, $style, ‘N’);
$pdf->write2DBarcode($code, ‘QRCODE,M’, 601.75, 454, 18, 18, $style, ‘N’);

カテゴリー php