问题描述
我正在尝试使用 PHP 生成标签大小的 PDF 文档。 这在原理上是有效的,但我无法正确放置条形码(代码 128)下的文本。 文本从几个字母滑到下一行,但仍有空格。
if(isset($_POST["submit"]))
{
$name = "3359";
$first = "Battery Battery Battery";
require_once('tcpdf/tcpdf.PHP');
require_once('tcpdf/tcpdf_barcodes_1d.PHP');
$pdf = new TCPDF('P',PDF_UNIT,array(38,23),true,'UTF-8',false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetHeaderData('','',PDF_HEADER_TITLE,PDF_HEADER_STRING);
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN,PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA,PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont('helvetica');
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetMargins(PDF_MARGIN_LEFT,'5',PDF_MARGIN_RIGHT);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetAutopageBreak(true,1);
$pdf->SetFont('helvetica','B',14);
$pdf->AddPage(array(38,23));
$content = '';
$content = "_________";
$content2 = '';
$style = array(
'position' => '','align' => 'C','stretch' => false,'fitwidth' => true,'cellfitalign' => '','hpadding' => 'auto','vpadding' => 'auto','fgcolor' => array(0,0),'bgcolor' => false,'text' => false,'font' => 'helvetica','fontsize' => 1,'stretchtext' => 2
);
$pdf->Cell(0,1);
$pdf->SetXY(2.5,0.5);
$pdf->writeHTML($name);
$pdf->SetX(0);
$pdf->write1DBarcode($name,'C128A',30,6,0.8,$style,'N');
$pdf->SetX(2.5);
$pdf->SetFont('helvetica',8);
$pdf->writeHTML($first);
$pdf->Output('label.pdf','I');
}
这里应该作为测试 3 次电池并排,第 3 次“打印”在另一页上
我希望任何人都可以帮助我。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)