我使用以下代码生成一维条形码。
//set standard size for label 174mmx100mm, dont pass orientation as that seems to break things
$pdf = new tcpdf('', PDF_UNIT, array(174,100), true, 'UTF-8', false);
$pdf->IncludeJS("print(true);");
$pdf->SetFontSize(10);
// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
//set image scale factor
$pdf->setImageScale(1.53);
//turn off auto page breaks which aren't useful here
$pdf->SetAutoPageBreak(false);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// set JPEG quality
$pdf->setJPEGQuality(100);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetDisplayMode('real', 'SinglePage');
$style = array(
'position' => '',
'align' => 'C',
'stretch' => false,
'fitwidth' => true,
'cellfitalign' => '',
'border' => false,
'padding' => 0,
'hpadding' => 'auto',
'vpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false, //array(255,255,255),
'font' => 'helvetica',
'fontsize' => 8,
'stretchtext' => 4
);
$pdf->Text(self::pxtomm(124), self::pxtomm(206), $la_barcodedata['barcode']);
//tall 1d barcode
$pdf->write1DBarcode('2245950000007601AKL001AS', 'C128B', self::pxtomm(72), self::pxtomm(226), self::pxtomm(279), self::pxtomm(57), 0.4, $style, 'N');
// The conversion method just for reference
private function pxtomm($pi_pixels)
{
return $pi_pixels * 0.264583333;
}
现在问题是生成的pdf文档在IE,FF,Chrome中看起来不同。无法扫描从IE打印的所有条形码,因为条形码线重叠并使其看起来像一个块。如果我放大和缩小,我可以看到明显的线条,但不能看到实际的页面适合大小。
避免这种情况并使其在所有浏览器中保持一致的最佳方法是什么?