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 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器