There is a html page.

<div id="description" > 

 <h2>Умей действовать при пожаре</h2> <div style="text-align: center"><Img src="/images/goods/1552_zagl.jpg" border="0" alt="Оформление кабинета ОБЖ" title="Оформление кабинета ОБЖ" style="margin: 0 3px;"></div> <h3>Краткое описание:</h3> <div id="description_tab"></div> <table> <Tr> <Td colsapn=2 vAlign="top" class="chnamecell"> <Span class="smalltext"><B>Параметры:</B></Span><Br /> </Td> </Tr></table><table> <Tr> <Td width="30%" vAlign="top" class="chnamecell"> <Span class="smalltext"><B>Размер</B></Span><Br /> </Td> <Td width="70%" vAlign="top" class="chvaluecell"> <Span class="smalltext">2,8 х 1,0 м</Span><Br /> </Td> </Tr></table><table> <Tr> <Td width="30%" vAlign="top" class="chnamecell"> <Span class="smalltext"><B>Вес</B></Span><Br /> </Td> <Td width="70%" vAlign="top" class="chvaluecell"> <Span class="smalltext">8,3 кг</Span><Br /> </Td> </Tr></table> <p>Бренд: NATIONAL® </p> <p>Цена производителя: 9800 руб.</p> <p>Код производителя: 10633</p> <p>Стенд сборный. Комплектующие изготовлены из противоударного полистирола УПС-825,методом литья под давлением в пресс-формах с окрашиванием в массе исходного полимера.<br> Размеры элементов:<br> Ячейка А4 формата - 250 х375 х 25 мм<br> Ячейка А3 формата - 375 х500 х 25 мм<br> Фриз 125 х125 х 20 мм<br> Сектор 125х125 х 20 мм<br> Овал 125хх125 х20 мм<br> Плакаты А4, А3 форма<br> Сертификат (соответствие) не требуется.<br> Клас безопасности по ОПБ 88/97 - 4н.<br> Дополнительно: модификации базовой сборки могут отличаться (цвет, заголовок стенда, логотипы) – информируется доп. соглашением. </p> 

It contains such a div - from it you need to create a .doc .docx document.
I tried html-docx-js, however, the resulting files are read only in Word.
I tried to use this function:

 function get_doc() { var a = document.createElement('a'); var data_type = 'data:application/vnd.openxmlformats-officedocument.wordprocessingml.document'; var table_div = document.getElementById('desc_main_1'); var table_html = table_div.outerHTML.replace(/ /g, '%20'); a.href = data_type + ', ' + table_html; a.download = 'planerka_table_' + '.doc'; a.click(); } 

Here, on the contrary, in the libra office works (with bugs), but some browsers stupidly keep the markup. Are there any ways to javascript or php?

    1 answer 1

    It is much easier to save in pdf, for this there are so many libraries, in particular DOMPDF, which allows you to export html to pdf. With dok, everything is much more complicated, but if the html is always the same, you can use the PHPWord library , and generate .doc on the fly, substituting values.

    • And you used this library. I put it, made this basicExample phpword.readthedocs.io/en/latest/general.html , but it’s just an empty file. - votanko
    • figured out, it turns out he keeps the document on the server, and is it possible to save the document on the client machine? - votanko
    • You can use the crutch, save it on the client machine, and delete it on the server - venanen