我想通过TCPDF设置一些文本块.但是我的字体大小有些问题.第一个文本块在x-y / 5-5上,字体大小为5到.但它比5更小.TCPDF中的字体大小与其他维度的字体大小不同?
$text1 = 'AAAg';
$text1_x = 5;
$text1_y = 5;
$text1_font_size = 5;
$text2 = 'BBBg';
$text2_x = 10;
$text2_y = 10;
$text2_font_size = 10;
$text3 = 'CCCg';
$text3_x = 15;
$text3_y = 15;
$text3_font_size = 15;
// I tried $pdf->Cell and $pdf->Text... both are doing the same...
解决方法:
好的我找到了答案和解决方案.当我们在tcPDF中创建新的PDF文档时,尺寸单位整个文档可以采用mm,cm,pt,px等格式.但字体是点 – pt.
解决方案……
>使用’setPageUnit’设置文档单元.
>如果我们有像素尺寸,我们必须将其转换为’pixelsToUnits’.
PHP – tcPDF示例:
$pdf->setPageUnit('pt');
$document_width = $pdf->pixelsToUnits('100');
$document_height = $pdf->pixelsToUnits('100');
$x = $pdf->pixelsToUnits('20');
$y = $pdf->pixelsToUnits('20');
$font_size = $pdf->pixelsToUnits('20');
$txt = 'AAAg';
$pdf->SetFont ('helvetica', '', $font_size , '', 'default', true );
$pdf->Text ( $x, $y, $txt, false, false, true, 0, 0, '', false, '', 0, false, 'T', 'M', false );