dounao1875
2019-03-21 17:49
浏览 337
已采纳

mPDF:生成完全类似于打印预览的PDF

I am using mPDF through PHP in order to generate an exact replica PDF of an HTML page. This PDF is then being saved to the server so that it can be automatically printed for the user through PHP socket programming.

When I print preview the HTML page, it looks exactly as I would want it printed. When I convert the HTML to a PDF with mPDF, it becomes wide and distorted. I just want it to look exactly like the HTML print preview with no changes.

Here is my PHP code:

require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();

ob_start();
include 'cert.html';
$html = ob_get_contents();
ob_end_clean();

$mpdf->WriteHTML($html);
$mpdf->Output();
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanbanzhi4419 2019-03-22 06:27
    已采纳

    Ditch mPDF and use a browser based library such as wkhtmltopdf.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题