douxun4173 2013-11-15 11:33 采纳率: 0%
浏览 272

html2pdf将html从url转换为pdf

Trying to generate PDFs with html2pdf. I want to generate using a URL.

The code I have generates a PDF, but the PDF is blank which, I assume, means not HTML is being pulled from the specified url.

require_once(dirname(__FILE__).'/html2pdf.class.php');
$url = 'http://example.com/survey/exportpdf.php?id=6';
try
{
    $html2pdf = new HTML2PDF('P', 'A4', 'en');
    //$html2pdf->setModeDebug();

    $html2pdf->getHtmlFromPage($url);

    $html2pdf->Output($id.'.pdf','D');
}
catch(HTML2PDF_exception $e) {
    echo $e;
    exit;
}

Is anyone familiar with html2pdf? I've gone through the docs and the examples, but I can't find any reference to this method. I've found the definition here, but it doesn't tell much.

  • 写回答

1条回答 默认 最新

  • douyingbei1458 2013-11-15 12:14
    关注

    use the below code to get the url html :

    $html = file_get_contents($url);
    $html2pdf->writeHTML($html, isset($_GET['vuehtml']));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?