0

hi
please do tell me how to convert a microsoft word to html document.
In my appln the user will browse the microsoft word document,when a registered user tries to view the application loaded by the users of the website...it should display in html format....

11
Contributors
14
Replies
36
Views
9 Years
Discussion Span
Last Post by diafol
0

In word do:
File -> Save as.. -> Type name and select webpage (*.htm,*.html) in the extension menu.

This is the only way to convert .doc to .html. Microsoft is very protective about there fileformats.
(well you could get a morgage and buy the microsoft SDK..)

Edited by Nick Evan: n/a

0

I strongly advise you to NOT use Word as a tool to create web pages. The Microsoft HTML conversion utility generates horrible code.

0

I strongly advise you to NOT use Word as a tool to create web pages. The Microsoft HTML conversion utility generates horrible code.

yea!

0

hi,
in my application the user will upload a word document...but when the admin open the page it should get displayed in html format.i want the conversion to automatic....................

0

Kings,

I asked a similar question in this forum before I saw your post. I've been doing some additional research since I posted and found a PHP script that is suppose to convert word docs to HTML automatically with the help of free program called "wvWare".

The script is located here: http://instruform.com/wordconv.phps

wvWare is located here: http://wvware.sourceforge.net/

Now I don't have any idea if these will work, but will be looking into them further for my own purposes. I hope this helps.

Good luck!

Yproc

0

Me too facing the same problem if any one finds solution then let me inform.The problem is about writing whole php code to convert a MS Word document to HTML format which i am using to upload resume.

0

I've tried to use ConvertDoc to convert word and pdf resumes to html code. Unfortunately, it doesn't get invoked from PHP. The shell takes the command fine, my php safe mode is off, and I have all permission to the System user on the executable. My code is below; I don't see any problem with it.

<?php
      $command='convertdoc /S resume_sd.doc /T resume_new.html /M2 /C2 /F9';
      echo $command;
      echo exec($command);
?>

Is there a remedy for this?

Edited by atichtch: n/a

0

This sounds like a particularly horrible thing to try and achieve. You probably need to use COM. I bet the various versions of Word will also throw a spanner in the works. If such a script exists, I reckon it'll be a commercial thing.

As for the wvware - it's C++ I think.

0
<?php
function content($file){
$data_array = explode(chr(0x0D),fread(fopen($file, "r"), filesize($file)));
$data_text = "";
foreach($data_array as $data_line){
if (strpos($data_line, chr(0x00) !== false)||(strlen($data_line)==0))
{} else {if(chr(0)) {$data_text .= "<br>";
$data_text .= preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$data_line); 
       } 
   }        
}
return $data_text;}
$file = "/home/user/file.doc";
$data = content($file);
echo $data;
?>

This PHP Code Converts the $file supplied into HTML and Display's it on a webpage.

0

// This is an improvement on the the last post adding uploading your Doc file to be Displayed

<?php
function content($file){
$data_array = explode(chr(0x0D),fread(fopen($file, "r"), filesize($file)));
$data_text = "";
foreach($data_array as $data_line){
if (strpos($data_line, chr(0x00) !== false)||(strlen($data_line)==0))
{} else {if(chr(0)) {$data_text .= "<br>";
                      $data_text .= preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$data_line); 
       } 
   }        
}
return $data_text;}
$destination = str_replace('index.php', '', $_SERVER['SCRIPT_FILENAME']);
$destination.= "upload/";
$maxsize = 5120000;
if (isset($_GET['upload'])) {
      if($_FILES['userfile']['name'] && $_FILES['userfile']['size'] < $maxsize) {
      if(move_uploaded_file($_FILES['userfile']['tmp_name'], "$destination/".$_FILES['userfile']['name'])){
      $file = $destination."/".$_FILES['userfile']['name'];
      $data = content($file);
      echo $data;
        }   
         }
}else{
      echo "<form  enctype='multipart/form-data' method='post' action='index.php?upload'>
            <input name='userfile' type='file'>
            <input value='Upload' name='submit' type='submit'>
            </form>";
      }
?>

Edited by forever99: improvement: adding Uploading of Files

0

Hi All,

Below code for .doc, doesn't covert header-footer part into TEXT:-

function content($file){
$data_array = explode(chr(0x0D),fread(fopen($file, "r"), filesize($file)));
$data_text = "";
foreach($data_array as $data_line){
if (strpos($data_line, chr(0x00) !== false)||(strlen($data_line)==0))
{} else {if(chr(0)) {$data_text .= "<br>";
$data_text .= preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$data_line); 
       } 
   }        
}
return $data_text;}
$html = content($userDoc);

:: My requirement is to convert .doc/.docx/.rtf file into HTML. Can anybody help to read header-footer part as well into text.

Thanks in advance
Nitin

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.