https://github.com/jackadams/meteor-html2docx
https://github.com/jackadams/meteor-html2docx
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jackadams/meteor-html2docx
- Owner: JackAdams
- License: mit
- Created: 2015-06-08T16:30:24.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-06-30T04:50:10.000Z (about 10 years ago)
- Last Synced: 2025-10-19T12:39:57.927Z (9 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
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
`
HTML to be turned into a docx file`
(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
`linkTitle="Download as Word document"` puts a title 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`)
`useDocNotDocx=true` produces `.doc` file instead of a `.docx` file (added because Word 2016 won't open html files with extension changed to `.docx` but it will open `.doc` files made this way)
#### Warning
This is not going to work in all browsers. See [this post](http://www.effectiveui.com/blog/2015/02/23/generating-a-downloadable-word-document-in-the-browser/) (from which inspiration for this package was drawn), and note that this package only uses the `download` attribute of the `` 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."