Skip to content

iclae/rich-to-word

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rich-to-word

NPM version NPM downloads

Installation

npm install rich-to-word

Use

import richToWord from rich-to-word;

const richText = `<p>hello rich-to-word</p><p><img src="https://avatars.githubusercontent.com/u/8125081?v=4" alt="" data-href="" style=""/></p>`

const blob = await richToWord(html);
const link = document.createElement('a');
const blobUrl = window.URL.createObjectURL(blob);
link.href = blobUrl;
link.download = 'word.docx';
link.click();

or

import { richToWordSave } from 'rich-to-word';
// use file-saver to download

const richText = `<p>hello rich-to-word</p><p><img src="https://avatars.githubusercontent.com/u/8125081?v=4" alt="" data-href="" style=""/></p>`;

richToWordSave(richText, 'word');
// await richToWordSave(richText, 'word');

Options

richToWord(richText, options)

richToWordSave(richText, fileName, options)

  • [imgDefaultStyle] (string): set img default style
  • [disablePreprocess] (boolean): if need to handle it yourself, disable the default style

Use in Vite

see rich-to-word-vite

LICENSE

MIT

About

rich text convert to docx

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published