【问题标题】:show images in html2pdf library在 html2pdf 库中显示图像
【发布时间】:2012-07-25 18:07:57
【问题描述】:

我有一个包含多行的表,每行都有一个图像。

<table>
   <tr>
       <td style="">
          <img src="<?php echo $img_path; ?>" />
              <?php echo ucwords($name); ?>
       </td>
       <td style="">
          <span style="border-bottom: 1px solid;margin-left: 98px;">
              <?php echo $date; ?></span>
       </td>
   </tr>
   <tr>
       <td>
          <?php echo $role; ?> 
            Signature
       </td>
       <td style="">
          Date
       </td>
   </tr>
</table>

是否可以在 HTML2PDF 中显示 html 中显示的图像而不是使用他的内置函数?

【问题讨论】:

    标签: php html2pdf


    【解决方案1】:
    <?php
    require('html2fpdf.php');
    $pdf=new HTML2FPDF();
    $pdf->AddPage();
    $fp = fopen("sample.html","r");
    $strContent = fread($fp, filesize("sample.html"));
    fclose($fp);
    $pdf->WriteHTML($strContent);
    $pdf->Output("sample.pdf");
    echo "PDF file is generated successfully!";
    ?>
    

    或者,您可以使用 TCPDF 并可以尝试like this

    $content='<img src="sample.jpg">';
    $html = <<<EOD
    $content
    EOD;
    $pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
    $pdf->Output("sample.pdf", 'F');
    

    【讨论】:

    • 他们是关于“致命错误:调用未定义的方法 HTML2PDF::AddPage()”的错误
    • 你包含 fpdf.php 了吗??
    • 从这里下载完整的 zip sourceforge.net/projects/html2fpdf 它将工作..
    • 我已经下载了最新版本的库并进行了配置:),但他的问题是这个库使用他自己的函数来渲染图像,他们是否以任何方式提供他的图像在 html 和它按原样显示?
    • 你可以检查这个tcpdf.org/examples.php TCPDF 更容易,有很多例子,很容易给你 html 中 标签的 pdf 文件
    猜你喜欢
    • 2019-01-18
    • 2022-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-24
    • 1970-01-01
    • 2017-11-30
    相关资源
    最近更新 更多