php – TCPDF:如何以正确的方式设置FONT SIZE
发布时间:2020-12-13 21:58:28 所属栏目:PHP教程 来源:网络整理
导读:我想通过TCPDF设置一些文本块.但是我的字体大小有些问题.第一个文本块在x-y / 5-5上,字体大小为5到.但它比5更小.TCPDF中的字体大小与其他维度的字体大小不同? PHP $text1 = 'AAAg';$text1_x = 5;$text1_y = 5;$text1_font_size = 5;$text2 = 'BBBg';$text2_
我想通过TCPDF设置一些文本块.但是我的字体大小有些问题.第一个文本块在x-y / 5-5上,字体大小为5到.但它比5更小.TCPDF中的字体大小与其他维度的字体大小不同?
PHP $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... Web example. 解决方法
好的我找到了答案和解决方案.当我们在tcPDF中创建新的PDF文档时,尺寸单位整个文档可以采用mm,cm,pt,px等格式.但字体是点 – pt.
解决方案…… >使用’setPageUnit’设置文档单元. 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,true,'T','M',false ); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |