微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

TCPDF使用writeHTML获得间距问题

如何解决TCPDF使用writeHTML获得间距问题

我正在使用html创建pdf。下面是我的代码

$pdf = new TCPDF(PDF_PAGE_ORIENTATION,PDF_UNIT,PDF_PAGE_FORMAT,true,'UTF-8',false);


$pdf->SetMargins(15,20,14,0);
$pdf->SetAutopageBreak(TRUE,0);
$pdf->setCellPaddings(0,0);
$pdf->setFooterMargin(0);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

// add a page
$pdf->AddPage();

    $html = '
    <div style="background-color: #f8f8f8;">

    <div style="font-size: 24px; color: #333; font-weight: 600; font-family:Arial,Helvetica,sans-serif;">Example</div>

    <p style="color: #828282; font-size: 14px; font-family: sans-serif;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
    Lorem Ipsum has been the industry standard dummy text ever since the 1500s,when an unkNown printer took a galley of type and scrambled it to make a type
    specimen book. It has survived not only five centuries,but also the leap 
    into electronic typesetting,remaining essentially unchanged. It was popularised 
    in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,and more recently with desktop publishing software like Aldus PageMaker including 
    versions of Lorem Ipsum.</p>
  </div>';

$pdf->writeHTML($html,false,'');

$pdf->Output('example_001.pdf','I');

由于某种原因,标题和文本之间会有空格

enter image description here

此外,每当我添加行高样式以在段落中的行之间留出一些空间时,它只会留下更大的空隙。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。