dongxing5525 2012-07-24 08:23
浏览 50
已采纳

在html2pdf库中显示图像

I have a table contains multiple rows and each row has an image.

<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>

Is it possible in HTML2PDF to show images as shown in html rather than using his built in functions?

  • 写回答

1条回答 默认 最新

  • dongli9894 2012-07-24 08:46
    关注
    <?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!";
    ?>
    

    Alternatively, you may use TCPDF and can try 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');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决