D
D
Diamond2015-06-07 17:47:09
PHP
Diamond, 2015-06-07 17:47:09

How to convert ms word document to html?

Hello!
I need a document from word (doc, docx) to be converted and inserted into a text field (tinyMCE), or immediately converted and uploaded to the database. It is also desirable that the pictures are uploaded to a separate folder. There are such converters on the Internet with the functionality I need, for example this one .
I also found an option that works through the COM interface, but I can't make it work. And what about the pictures?

<?php
// htmlviewer.php
// convert a Word doc to an HTML file
//$DocumentPath = str_replace("\\", "\", $DocumentPath);
$DocumentPath="C:/Archivos de programa/Easyphp/www/subidas/curric.doc";
// create an instance of the Word application
$word = new COM("word.application") or die("Unable to instantiate application object");
// creating an instance of the Word Document object
$wordDocument = new COM("word.document") or die("Unable to instantiate document object");
$word->Visible = 0;
// open up an empty document
$wordDocument = $word->Documents->Open($DocumentPath);
// create the filename for the HTML version
$HTMLPath = substr_replace($DocumentPath, 'txt', -3, 3);
// save the document as HTML
$wordDocument->SaveAs($HTMLPath, 3);
// clean up
$wordDocument = null;
$word->Quit();
$word = null;
// redirect the browser to the newly-created document header("Location:". $HTMLPath);
header("Location:". $HTMLPath);
?>

And as far as I understand, this code will simply create an html file, and I need exactly the code, without the main tags, although this is already clear.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AVKor, 2015-06-07
@AVKor

pandoc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question