Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. $step = 1;
  2. $height = 50;//не помню точно, надо подрегулировать будет
  3. $barcode = 'fm00000000705';//example
  4.  
  5. function generatePdf($html, $barcode, $type = 'svg' ) {
  6.    
  7.     $mpdf = new \Mpdf\Mpdf([
  8.     'mode' => 'utf-8',
  9.     'format' => [20, 30],
  10.     'orientation' => 'L',
  11.     'setAutoTopMargin' => 'stretch',
  12.     'autoMarginPadding' => 0,
  13.     'bleedMargin' => 0,
  14.     'crossMarkMargin' => 0,
  15.     'cropMarkMargin' => 0,
  16.     'nonPrintMargin' => 0,
  17.     'margBuffer' => 0,
  18.     'collapseBlockMargins' => false,
  19.     'margin_left' => 0,
  20. 'margin_right' => 0,
  21. 'margin_top' => 0,
  22. 'margin_bottom' => 0,
  23. 'margin_header' => 0,
  24. 'margin_footer' => 0
  25. ]);
  26.   if($type != 'svg') $mpdf->img_dpi = 203;
  27.   $mpdf->WriteHTML($html);
  28.   //save the file put which location you need folder/filname
  29.   $mpdf->Output(DIR_BARCODE_IMG.$barcode."_".$type.".pdf", 'F');
  30.  
  31. }
  32. $generator = new Picqer\Barcode\BarcodeGeneratorPNG();
  33.  
  34. 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