我正在尝试为Zebra打印机打印条形码标签。我正在使用TCPDF生成并保存pdf。不幸的是,生成了pdf,但是只有当我有2页时(例如),才打印第二页。我也尝试设置首选项,并在激光打印机上尝试过,即使有纸也可以在一张纸“装入纸”后显示消息。
我尝试设置首选项,但在激光上也仍然倒置。我应该关注Zebra和Laser中的任何设置吗?
public function createpdf($list_array) {
$this->load->library('Pdf');
// create new PDF document
$pdf = new Pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
//$pdf->SetProtection(array('print'), '', null, 0, null);
$pdf->SetAutoPageBreak(TRUE, 0);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->SetMargins(PDF_MARGIN_LEFT+10, PDF_MARGIN_TOP-10, PDF_MARGIN_RIGHT);
// set a barcode on the page footer
//$pdf->setBarcode(date('Y-m-d H:i:s'));
// set font
$pdf->SetFont('helvetica', '', 11);
$preferences = array(
'Duplex' => 'DuplexFlipLongEdge', // Simplex, DuplexFlipShortEdge, DuplexFlipLongEdge
'PickTrayByPDFSize' => true,
'PrintPageRange' => array(2,1),
'NumCopies' => 1
);
$pdf->setViewerPreferences($preferences);
// add a page
$pdf->AddPage();enter code here
// define barcode style
$style = array(
'position' => '',
'align' => 'C',
'stretch' => false,
'fitwidth' => true,
'cellfitalign' => '',
'border' => true,
'hpadding' => 'auto',
'vpadding' => 'auto',
'fgcolor' => array(0, 0, 0),
'bgcolor' => false, //array(255,255,255),
'text' => true,
'font' => 'helvetica',
'fontsize' => 8,
'stretchtext' => 4
);
//63.5 mm label width
//33.9mm label height
//2.5 mm gap between
// Here get list of all barcodes
$counter = 1;
for ($i = 0; $i < count($list_array); $i++) {
if ($counter == 5) {
// add a page
// set auto page breaks
// $pdf->SetAutoPageBreak(TRUE, 0);
$pdf->AddPage();
$counter = 1;
} else {
$counter++;
}
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->setCellMargins(0, 0, 4.5, 0);
$pdf->write1DBarcode($list_array[$i]->uniq_id, 'C39', $x - 2.5, $y - 6.5, 63.5, 18, 0.4, $style, 'L');
$pdf->SetXY($x, $y);
$pdf->Cell(58.5, 35, $list_array[$i]->project_id." [ ".$list_array[$i]->style_number." ]", 0, 0, 'C', FALSE, '', 0, FALSE, 'C', 'B');
$pdf->SetXY($x, $y);
$pdf->Cell(58.5, 43,$list_array[$i]->description , 0, 0, 'C', FALSE, '', 0, FALSE, 'C', 'B');
$pdf->SetXY($x, $y);
$pdf->Cell(58.5, 51,"Color:".$list_array[$i]->attr_2." Quantity:".$list_array[$i]->qty." Size:".$list_array[$i]->size, 0, 0, 'C', FALSE, '', 0, FALSE, 'C', 'B');
$pdf->SetXY($x, $y);
$pdf->Ln(53.9);
}
// pre($pdf);
// ---------------------------------------------------------
// ob_end_clean();
//Close and output PDF document
$pdf->Output('barcodes.pdf', 'D');
}