处于横向的PDF库tcpdf和pdf-> SetXY不能按预期工作吗? [英] PDF library tcpdf in landscape orientation and pdf->SetXY doesn't work as expected?
问题描述
如果方向是横向的,我无法弄清楚tcpdf如何重新计算x和y坐标.我可以控制的唯一方法是将文本放入writeHTML
I can not figure this one out how tcpdf recalculates x and y coordinates if orientation is landscape. The only way i can get a bit of control is to put text in a 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码的右侧.多行(如果名称很长且文本左对齐)?有提示,建议吗?
Ideally I like to layout the text on the right of the QR code. Multiline if a name is very long and text-align left?? Any tips, suggestions?
推荐答案
对于在我这种情况下处于相同情况的用户,$ pdf-> MultiCell可以完成此工作,因为我不知道一个名称将包含多少个字符.而且使用表格单元格不会让我在多行上显示名称
For those in the same situation in my case $pdf->MultiCell did the job as I don't know how many characters a name will have. And using a table cell would not let me display a name on multiline
$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);
这篇关于处于横向的PDF库tcpdf和pdf-> SetXY不能按预期工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!