【发布时间】:2012-01-28 22:07:05
【问题描述】:
我正在尝试创建带有要打印在标签页上的正确边距的条形码的 PDF 页面(如果您对如何在不生成 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');
}
}
我目前收到错误“第 79 行 () 上的 library/Zend/Pdf/FileParserDataSource/File.php 中的文件路径无效”
对为什么会发生这种情况有任何想法吗?当我尝试渲染条形码时会发生这种情况。在此之前代码执行没有错误。
【问题讨论】:
-
第 79 行是我在 Zend_Barcode::factory 上调用 render() 的那一行
标签: zend-framework pdf-generation barcode