我正在尝试创建具有条形码的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');
}
}我当前收到一个错误消息"Invalid file path in: library/Zend/Pdf/FileParserDataSource/File.php on line 79 ()“。
对于为什么会发生这种情况,有什么想法吗?当我尝试渲染条形码时,就会发生这种情况。在此之前,代码执行时没有任何错误。
发布于 2012-01-30 03:42:02
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK-1', 'font' => __DIR__ . "/FRE3OF9X.TTF"); TTF文件(FRE3OF9X.TTF或其他文件)必须存在。
发布于 2012-10-09 22:36:36
我相信你的问题的完整答案已经添加到这里:Zend Framework Render Barcodes Into Multiple PDF Pages with other content
关键似乎是:
Zend_Barcode::factory('code39', 'pdf', $barcodeOptions, $rendererOptions)->setResource($pdf, $page_index)->draw();的工具将条形码库条形码打印到pdf的该页面上
https://stackoverflow.com/questions/9049046
复制相似问题