Opening a .doc file, which is actually an HTML file, as a .doc file

2

My software generates .doc files which are actually HTML files but with the ".doc" extension.

When I open them in Microsoft Office they open as a .doc file and the user does not know that it is actually an .html file.

However, when I open them in LibreOffice or OpenOffice they are opened as a text file showing the HTML markup.

How can I create a HTML file with a ".doc" extension that opens as a .doc file in LibreOffice?

Here is a sample of one of the files:

<!doctype html><html><head><meta charset="utf-8" /><title>" </title><style>table, tr, th, td { border: 1px solid #333; border-collapse: collapse; direction: rtl; } table { margin: 10px; } th, td { padding: 10px; } </style></head><body dir="rtl"><h1>" </h1>: 01.07.2018 - 31.07.2018<br /><br /><h3> </th><td></td></tr></table><br /><h3> : </h3><table><tr><th> </th></tr><tr><td></td><td></td></tr></table></body></html>

(Please note that I use Hebrew UTF8 inside the files.)

Aviv

Posted 2018-08-27T19:59:53.500

Reputation: 558

1The example html you posted opened as a text document in my LO, no html tags at all. Try to reset LO settings to default – Alex – 2018-08-27T20:20:33.083

1As @Alex states, using LibreOffice Writer v. 6.1.0.3, the file is displayed as HTML, showing just a quote as heading1 and date-time below. Writer displays the file this way whether it has .DOC or .HTML extension. – DrMoishe Pippik – 2018-08-27T21:15:51.280

Got it, thanks. Anyhow the problem was in the encoding. I started using Windows-1255 and all problems gone. Should I answer my own question ? – Aviv – 2018-08-27T21:52:33.743

Answers

0

Got it, thanks. Anyhow the problem was in the encoding. I started using Windows-1255 and all problems gone.

  $data = mb_convert_encoding($data, 'ISO-8859-8', 'UTF-8');

ISO-8859-8 and Windows-1255 are basically the same.

Aviv

Posted 2018-08-27T19:59:53.500

Reputation: 558