我无法弄清楚如果方向是横向的,tcpdf如何重新计算x和y坐标。我可以获得一点控制的唯一方法是将文本放在writeHTML
中// QR code
$style = array(
'border' => false,
'padding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false
);
$pdf->SetXY(0, 0);
$pdf->write2DBarcode('http://www.google.com/', 'QRCODE,H', 0, 1, 40, 40, $style, 'N');
// set text content
$pdf->SetXY(2, 37);
//$pdf->SetXY(30, 7);
$pdf->SetFontSize(10);
$textData = '<p>Matthew Pitt</p>'
. '<p>Google Light Company</p>';
$pdf->writeHTML($textData, true, false, false, false, 'R');
,结果是
理想情况下,我喜欢在QR码的右侧布置文本。如果名称很长并且文本对齐,那么多行?有什么提示,建议吗?
答案 0 :(得分:0)
对于那些我的情况相同的情况$ pdf-&gt; MultiCell完成了这项工作,因为我不知道名字会有多少个字符。使用表格单元格不允许我在多行显示名称
$style = array(
'border' => false,
'padding' => 'auto',
'fgcolor' => array(0, 0, 0),
'bgcolor' => false
);
$pdf->SetXY(0, 0);
$pdf->write2DBarcode('http://www.google.com/', 'QRCODE,H', 0, 1, 40, 40, $style, 'N');
// set text content
$pdf->SetXY(42, 7);
$pdf->SetFontSize(10);
//
$textData = '<p>Matthew Pitt</p>'
. '<p>Google Light Company</p>';
//$pdf->writeHTML($textData, true, false, false, false, 'L');
$pdf->SetXY(40, 7);
$htmlHead = '<table width="250" border="0">
<tr>
<td align="left">Matthew Pitt Matthew Pitt Matthew Pitt</td>
</tr>
<tr>
<td align="left">Good Light Company</td>
</tr>
</table>';
//$pdf->writeHTML($htmlHead, true, false, true, false, '');//<- check this didn't work 100% correctly
$txt = 'Matthew Pitt Matthew Pitt Matthew Pitt Matthew Pitt Matthew Pitt Matthew Pitt';
$pdf->MultiCell(45, 5, $txt, 0, '', 0, 1, '', '', true);
$pdf->Ln(1);
$pdf->SetX(40);
$txt2 = 'Google Company Light';
$pdf->MultiCell(45, 5, $txt2, 0, '', 0, 1, '', '', true);