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.)

  • 1
    The 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 Aug 27 '18 at 20:20
  • 1
    As @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 Aug 27 '18 at 21:15
  • 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 Aug 27 '18 at 21:52
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.