简体   繁体   English

使用php将pdf,doc,ppt,xls文件转换为html

[英]Convert pdf,doc,ppt,xls files to html using php

Actually I want all files view as html like gmail in view as html. 实际上,我希望所有文件都以html的形式像gmail一样以html形式查看。

I have used below code for doc view as html but here not displaying font style (bold,color,etc...) 我已经将以下代码用于html的doc视图,但此处未显示字体样式(粗体,颜色等)

function parseWord($userDoc) 
{
    $fileHandle = fopen($userDoc, "r");
    $line = @fread($fileHandle, filesize($userDoc));   
    $lines = explode(chr(0x0D),$line);
    $outtext = "";
    foreach($lines as $thisline)
      {
        $pos = strpos($thisline, chr(0x00));
        if (($pos !== FALSE)||(strlen($thisline)==0))
          {
          } else {
            $outtext .= $thisline." ";
          }
      }
     $outtext = preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$outtext);
    return $outtext;
} 

$userDoc = "cv.doc";

$text = parseWord($userDoc);
echo $text;

?>

Is there any way to view all files as html for display in browser? 有什么方法可以将所有文件查看为html格式,以便在浏览器中显示? I am not interested in use plugins and any s/w. 我对使用插件和任何软件都不感兴趣。

There is no such function available in PHP. PHP中没有此类功能。 You'll have to do everything on your own or rely on some software. 您必须自己完成所有工作或依靠某些软件。

If you change your mind about foreign software let us know. 如果您对外国软件改变主意,请告诉我们。

There are a few free tools that you can use to parse such documents. 您可以使用一些免费工具来解析此类文档。 Take a look here . 在这里看看。 There are even tools that convert doc and pdf sources directly into html, but we have never tested those. 甚至有一些工具可将doc和pdf源直接转换为html,但我们从未测试过。 Google here 谷歌在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM