/* eslint-disable no-console */ const fs = require('fs'); // FIXME: Incase you have the npm package // const HTMLtoDOCX = require('html-to-docx'); const HTMLtoDOCX = require('../dist/html-to-docx.umd'); const filePath = './example.docx'; const htmlString = ` Document

Taken from wikipedia

Red dot Red dot

This is heading 1

Content

This is heading 2

Content

This is heading 3

Content

This is heading 4

Content

This is heading 5

Content

This is heading 6

Content

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Where does it come from? Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.

Look at me, i'm a paragraph in Courier New!

Look at me, i'm a paragraph in SerifTestFont!

Look at me, i'm a paragraph in SansTestFont!

Look at me, i'm a paragraph in MonoTestFont!

For 50 years, WWF has been protecting the future of nature. The world's leading conservation organization, WWF works in 100 countries and is supported by 1.2 million members in the United States and close to 5 million globally.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Left indented paragraph: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Right indented paragraph: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Left and right indented paragraph: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.


  1. Ordered list element

Country Capital
India New Delhi
United States of America Washington DC
Bolivia
  1. Sucre
  2. La Paz

 

Example Header

Financial

Tech

Total Market

Level of Meme

High

GUSH

ARKK

SPLX

Medium

[̲̅$̲̅(̲̅ ͡° ͜ʖ ͡°̲̅)̲̅$̲̅]

TQQQ

( ͡~ ͜ʖ ͡°)

Low

( ◔ ʖ̯ ◔ )

QQQ

SPY

`; (async () => { const fileBuffer = await HTMLtoDOCX(htmlString, null, { table: { row: { cantSplit: true } }, footer: true, pageNumber: true, }); fs.writeFile(filePath, fileBuffer, (error) => { if (error) { console.log('Docx file creation failed'); return; } console.log('Docx file created successfully'); }); })();