【问题标题】:Generate html with images from pdf using Linux -poppler-utils-pdftohtml使用 Linux -poppler-utils-pdftohtml 从 pdf 生成带有图像的 html
【发布时间】:2013-04-22 10:12:57
【问题描述】:

目前我正在使用 pdftohtml,在 CentOS 下,poppler-utils。这个概念很简单 - 用户上传 PDF 文件并查看该文件的 HTML 版本。我使用简单的命令 -

$> pdftohtml source.pdf target.html 

但它不起作用!后来,我尝试使用没有框架的复杂开关创建html:

$> pdftohtml -c - noframes source.pdf target.html 

仍然没有运气!问题是 - pdf 文件的图像(图像在该 pdf 文件内)不能出现在 html 中,有时,图像重叠!有什么想法吗?

这是 PHP 代码 -

添加.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="css/style.css" rel="stylesheet" type="text/css"/>
<title>CompleteView</title>
</head>
<body>
 <form method="post" action="save.php" enctype="multipart/form-data">
       <input type="hidden" name="action" value="add">
        <tr class="dark_bgcolor text-content">
         <td align="left" width="20%">Upload</td>
         <td align="left" width="1%">:</td>
         <td align="left">
         <input type="file" name="img_full" class="look" size="50"> 
         (Only .pdf)
         </td>
       </tr>

       <tr class="bottom_bgcolor">
         <td align="center" colspan="3"><input type="submit" name="" value="Upload" class="look"></td>
       </tr>
       </form>
</body>
</html>

保存.php

<?php
$myNewFolderPath=rand();
mkdir($myNewFolderPath);
$fname="full_".uniqid("");
$filename=$fname.'.pdf';
//$uploadpath=SPL_IMG_UPLOADPATH.$filename;
move_uploaded_file($_FILES['img_full']['tmp_name'], $myNewFolderPath.'/'.$filename);
chmod($myNewFolderPath.'/'.$filename, 0777);
echo ('/usr/local/bin/pdftohtml '.$myNewFolderPath.'/'.$filename);
exec('/usr/local/bin/pdftohtml -c -noframes'.$myNewFolderPath.'/'.$filename);
header('Location:'.$fname.'.html');
//exec('/usr/local/bin/pdftohtml 2098602105/EssentialC.pdf');
?>

还有一点 - pdftohtml 版本是 -0.36

这里是截图 -

结果 -

【问题讨论】:

    标签: html linux pdf pdf-to-html


    【解决方案1】:
    $ pdftohtml -c source.pdf target.html 
    

    这将以复杂模式输出。您不能将 -noframes 与 complex 标志一起使用。

    $ man pdftohtml
    
     -noframes   generate no frames. Not supported in complex output mode.
    

    【讨论】:

      猜你喜欢
      • 2018-03-12
      • 2013-08-01
      • 2018-09-24
      • 1970-01-01
      • 1970-01-01
      • 2016-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多