我下载了 FPDF 1.7,并找到了一个基于 Avery 5160 标准的脚本,可以自动创建用于打印的标签 PDF。它似乎工作得很好,只是当我打印测试页时尺寸不匹配。当我测量为每个标签打印的容器盒时,我验证了输入的测量值与打印的测量值不匹配。
脚本是否存在我看不到的问题,或者 FPDF 不够精确,无法处理此问题?
function Avery5160($x, $y, &$pdf, $text) {
$left = 4.826; // 0.19" in mm
$top = 12.7; // 0.5" in mm
$width = 76.802; // 2.63" in mm
$height = 25.4; // 1.0" in mm
$hgap = 3.048; // 0.12" in mm
$vgap = 0.0;
$x = $left + (($width + $hgap) * $x);
$y = $top + (($height + $vgap) * $y);
$pdf->SetXY($x, $y);
$pdf->MultiCell($width, 5, $text, 1, 'C');
}
$pdf = new FPDF();
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont('Helvetica', 'B', 10);
$pdf->SetMargins(0, 0);
$pdf->SetAutoPageBreak(false);
$x = $y = 0;
foreach($arr as $text) {
Avery5160($x, $y, $pdf, $text);
$y++; // next row
if($y == 10) { // end of page wrap to next column
$x++;
$y = 0;
if($x == 3) { // end of page
$x = 0;
$y = 0;
$pdf->AddPage();
}
}
}
$pdf->Output('Labels.pdf', 'D');
最佳答案
我最近在工作中使用 FPDF 制作一些自定义标签。为了让它们与我使用的标签对齐,我必须在打印之前在“打印”对话框中禁用页面缩放。不知道它是否能解决您的问题,但值得一试。
关于php - 使用 FPDF 打印 Avery 5160 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8235262/