我试图创建带有正确页边距的条形码的PDF页面,并将其打印在标签上(如果您有另一个关于如何在没有生成PDF的情况下将条形码打印到标签上的想法, d爱听到它)。下面是我当前的代码:Zend Framework将条形码渲染为PDF页面
$pdf = new Zend_Pdf();
for($i = 1; $i <= $numberOfPages; $i++)
{
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 20);
$pdf->pages[] = $page;
}
foreach($pdf->pages as $id => $page)
{
if($equipmentCount > 10)
{
$barcodesOnThisPage = 10;
$equipmentCount = $equipmentCount - 10;
}
else
{
$barcodesOnThisPage = $equipmentCount;
}
for($i = 1; $i <= $barcodesOnThisPage; $i++)
{
//Zend_Barcode::setBarcodeFont();
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK-1');
$rendererOptions = array('topOffset' => 50);
$pdf = Zend_Barcode::factory('code39', 'pdf',
$barcodeOptions, $rendererOptions)->setResource($pdf)->render();
die;
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK-2');
$rendererOptions = array('topOffset' => 100);
$pdfBarcode = Zend_Barcode::factory('code39', 'pdf',
$barcodeOptions, $rendererOptions)->setResource($pdf)->draw();
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK-3');
$rendererOptions = array('topOffset' => 150);
$pdfBarcode = Zend_Barcode::factory('code39', 'pdf',
$barcodeOptions, $rendererOptions)->setResource($pdf)->draw();
// and the end render your Zend_Pdf
/$pdfBarcode->save('testBarcode.pdf');
}
}
我目前得到一个错误 “在无效的文件路径:库/的Zend/PDF/FileParserDataSource/File.php上线79()”
任何想法,为什么这是发生?当我尝试呈现条形码时会发生这种情况。在此之前,代码执行没有错误。
哪一个是线79的PDF页面吗? – ACNB 2012-01-29 16:09:26
79行是我在Zend_Barcode :: factory上调用render()的地方 – tubaguy50035 2012-01-30 19:02:47