Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $step = 1;
- $height = 50;//не помню точно, надо подрегулировать будет
- $barcode = 'fm00000000705';//example
- function generatePdf($html, $barcode, $type = 'svg' ) {
- $mpdf = new \Mpdf\Mpdf([
- 'mode' => 'utf-8',
- 'format' => [20, 30],
- 'orientation' => 'L',
- 'setAutoTopMargin' => 'stretch',
- 'autoMarginPadding' => 0,
- 'bleedMargin' => 0,
- 'crossMarkMargin' => 0,
- 'cropMarkMargin' => 0,
- 'nonPrintMargin' => 0,
- 'margBuffer' => 0,
- 'collapseBlockMargins' => false,
- 'margin_left' => 0,
- 'margin_right' => 0,
- 'margin_top' => 0,
- 'margin_bottom' => 0,
- 'margin_header' => 0,
- 'margin_footer' => 0
- ]);
- if($type != 'svg') $mpdf->img_dpi = 203;
- $mpdf->WriteHTML($html);
- //save the file put which location you need folder/filname
- $mpdf->Output(DIR_BARCODE_IMG.$barcode."_".$type.".pdf", 'F');
- }
- $generator = new Picqer\Barcode\BarcodeGeneratorPNG();
- generatePdf('<div style="margin-left: 6mm; width: 100%; "><img src="data:image/png;base64,' . base64_encode($generator->getBarcode($barcode, $generator::TYPE_CODE_128, $step, $height)) . '"></div><div style="font-size: 2.4mm; width: 100%; text-align: center;">'.$barcode.'</div>', $barcode, 'png');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement