2016-04-14 92 views
0

有谁知道如何在HTML2FPDF PHP库中包含CSS文件。我能够生成一个PDF文件,但风格不包括。目前,我正在HTML字符串($ my_html)的标题中附加样式表。在HTML2FPDF中添加CSS文件

这是我的代码。

$pdf = new HTML2FPDF(); 
      $pdf->AddPage(); 
      $pdf->WriteHTML($my_html); 
      $pdf->Output('pdffile_.pdf'); 

回答

0

望着Html2fpdf documentantion我没有发现任何方法,包括额外的文件到PDF输出文档,所以我认为最好的解决办法是串联到您的$my_html变量。见:

$my_html .= "<style>\n " . file_get_contents('path/to/style.css') . "</style>"; 

$pdf = new HTML2FPDF(); 
      $pdf->AddPage(); 
      $pdf->WriteHTML($my_html); 
      $pdf->Output('pdffile_.pdf'); 
+0

它不工作,我试过这一个。 – Ninju