Php TCPDF获取writeHTML的间距问题

Php TCPDF获取writeHTML的间距问题,php,tcpdf,Php,Tcpdf,我正在使用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,0,0); $pdf->setFooterMargin(0);

我正在使用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,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, false, true, false, '');

$pdf->Output('example_001.pdf', 'I');
$pdf=新的TCPDF(pdf页面方向,pdf单元,pdf页面格式,真,'UTF-8',假);
$pdf->SetMargins(15,20,14,0);
$pdf->SetAutoPageBreak(真,0);
$pdf->setCellPaddings(0,0,0,0);
$pdf->setFooterMargin(0);
$pdf->setPrintHeader(假);
$pdf->setPrintFooter(false);
//添加页面
$pdf->AddPage();
$html='1
例子
Lorem Ipsum只是印刷和排版行业的虚拟文本。
自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,
当一个不知名的印刷商拿着一个铅字厨房,把它拼凑成一个铅字
样本书。它不仅经历了五个世纪,而且还经历了一次飞跃
改为电子排版,基本保持不变。它被大众化了
20世纪60年代,随着包含Lorem Ipsum段落的Letraset表单的发布,
最近,像Aldus PageMaker这样的桌面发布软件包括
Lorem Ipsum的版本

'; $pdf->writeHTML($html,false,false,true,false,”); $pdf->Output('example_001.pdf','I');
由于某些原因,正如您所看到的,标题和文本之间有一个空格


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

您是否尝试将
边距设置为0;填充:0样式到文本段落和<代码> div <代码>包含<代码>示例< /C> >代码> > p> <代码>对于BOT和PATH都有默认余量,我希望TCPDF默认地考虑它们。尝试添加
边距:0在你的
样式中。我添加了两个
边距:0;填充:0
p和div
标记中,但仍不减少空间@Frankich@Lounis
$tagvs=array('p'=>array(0=>array('h'=>0,'n'=>0),1=>array('h'=>0,'n'=>0))$pdf->setHtmlVSpace($tagvs)您可以尝试添加这两行吗?看起来,
页边距
不支持作为TCPDF的CSS属性。现在工作很好,谢谢@Frankich