babrahams:html2docx

v0.1.3Published 9 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

HTML to docx

Meteor package for creating .docx files on the client from html.

Quick start

meteor add babrahams:html2docx

To create a link that triggers the download of a specified element as a .docx file:

{{> html2docx selector="#target-element"}}

with

<div id="target-element"><strong>HTML</strong> to be turned into a docx file</div>

(the selector parameter is required)

Options

When initiating the widget, use these parameters to configure it:

linkText="Download" changes the text of the link (default is "Download as Word document")

linkClass="my-class-for-links" puts a custom class attribute on the link (users of Bootstrap might use btn here)

linkStyle="text-decoration: none;" puts a custom style attribute on the link

css="h1 { color: red; }" adds a custom set of css rules to the .docx file that is generated

filename="my_word_doc" changes the name of the downloaded file (default is "export")

includeStylesheets=false means there will be no attempt to include css from the application's stylesheets (default is true)

Warning

This is not going to work in all browsers. See this post (from which inspiration for this package was drawn), and note that this package only uses the download attribute of the <a> tag. This will probably only work with recent versions of Chrome and Firefox.

Application styles will not appear in the .docx file as they appear in the app. To quote from the post above:

"Word supports a small, outdated subset of CSS. Properties such as background-color, color, font-size, font-weight, text-align, margin, and padding are supported. CSS3 selectors, as well as properties like float and position don’t work. You can give elements class and id attributes to target with a stylesheet."