This class can be used to convert HTML pages into Microsoft Word documents in the XML format.
It can parse a HTML document given as a HTML data string or a page URL. Then it extracts the HTML document header and body and rewrite it with a Microsoft Word document XML header.
Create Microsoft Word document without COM objects
This class can be used to generate documents in Microsoft Word .doc format without using COM objects so it can work under Linux or other non-Windows based servers.
It may be useful to generate and serve documents that may be edited by the end users using Microsoft Word or OpenOffice.
The class generates XHTML documents with special tags and attributes that Microsoft Word understands like any variant of the .doc format.
In Portuguese:
MsDocGenerator é uma classe para gerar arquivos DOC, sem utilizar objetos COM, o que permite sua utilização em servidores que não estão rodando o Windows.
A classe gera um documento HTML em um formato específico, que o MSWord interpreta como se este fosse um arquivo DOC.
Pode ser útil na geração de relatórios, os quais o usuário final queira fazer alterações usando o Word ou o OpenOffice.
This class can be used to edit Microsoft Word documents using COM objects.
It creates a COM object to communicate with an instance of Microsoft Word running on the same machine. Then it can execute several operations to manipulate Word documents.
Currently it can:
- Create a new document
- Open a document from an existing file
- Insert text in the current cursor position or at a given bookmark position
- Save the document to the current file or to a new file
- Close the document
- Close the Word instance
This class can be used to convert a Microsoft Word document to HTML, RTF or plain text using COM objects.
The input document formats can be Microsoft Word DOC, RTF and plain text.
The class can also clean the generated HTML to remove unnecessary markup that Microsoft Word adds.
Of course, you need MsWord installed on the server, and Windows OS.
It doesn't works ? Look below =>
1- your server must be running Win32
2- Microsoft Word must be installed on the server (I tested with Word2000)
3- readfile() is not available under PHP 4.3. You can use the following code to replace it with PHP<4.3
if (str_replace(".", "", phpversion())<"430")
{
function readFile( $f ) {
$out = ""; $lines = file ($f); foreach( $lines as $l ) $out .= $l."\n"; return $out;
}
}
4- try to not open a file on the netword (ie \\server\doc...) unless you fully understand the authentification process