douliangpo0128 2015-07-09 07:37
浏览 83

使用PHP将PDF转换为HTML

I need to convert some pdf files into HTML. I downloaded pdftohtml for PHP but I don't know how to use it. I am trying to run it with this code:

<?php  
    include 'pdf-to-html-master/src/Gufy/PdfToHtml.php';
    $pdf = new \Gufy\PdfToHtml;
    $pdf->open('1400.pdf');
    $pdf->generate();
?>

This results in a blank web page.

What do I need to modify? What is the correct code to run this script?

  • 写回答

3条回答 默认 最新

  • douzang7928 2015-07-09 07:54
    关注

    I use wkhtmltopdf and it works okay. You can download it from here: http://wkhtmltopdf.org/downloads.html

    I installed it in Linux and I use it like this:

    $url = "https://www.google.com";
    
    $command = "/usr/bin/wkhtmltopdf --load-error-handling ignore --disable-smart-shrinking -T 5mm -B 5mm -L 2mm -R 2mm  --page-size Letter --encoding utf-8 --quiet";
    
    $filename = '[file path].pdf';
    if (file_exists($filename)) {
       unlink($filename);
    }
    
    $output = shell_exec($command . " $url " . $filename);
    
    echo $output;
    

    Hope this helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号