Files
docx-js/README.md

92 lines
2.8 KiB
Markdown
Raw Normal View History

2017-03-07 23:10:35 +00:00
<p align="center">
<img alt="clippy the assistant" src="http://i60.tinypic.com/339pvtt.png">
</p>
<p align="center">
Generate .docx files with JS/TS very easily, written in TS.
2017-03-07 23:10:35 +00:00
</p>
2017-03-10 11:27:48 +00:00
2017-03-14 10:47:50 +00:00
-----
2017-03-07 23:10:35 +00:00
2017-03-13 16:14:03 +00:00
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][gemnasium-image]][gemnasium-url] [![Known Vulnerabilities][snky-image]][snky-url] [![Chat on Gitter][gitter-image]][gitter-url]
2017-03-07 23:12:08 +00:00
2016-07-19 19:02:44 +01:00
[![NPM](https://nodei.co/npm/docx.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/docx/)
2016-07-04 09:03:25 +01:00
2017-03-13 01:21:26 +00:00
# docx
## Install
2016-07-04 09:03:25 +01:00
```sh
$ npm install --save docx
```
2017-03-13 01:21:26 +00:00
## Demo
2017-03-12 21:37:36 +00:00
```sh
$ npm run demo
```
2017-04-17 19:53:53 +01:00
will run the demo selector app in the `demo` folder. It will prompt you to select a demo number, which will run a demo from that folder.
2017-03-12 21:37:36 +00:00
2017-03-13 01:21:26 +00:00
## Guide
2017-03-13 00:54:05 +00:00
Please refer to [the Wiki](https://github.com/dolanmiu/docx/wiki) for details on how to use this library, examples and much more!
2016-07-04 09:03:25 +01:00
2017-04-16 00:09:07 +01:00
Full documentation can be found here: [http://dolanmiu.github.io/docx](http://dolanmiu.github.io/docx)
2017-03-13 01:21:26 +00:00
## Simple Usage
2016-07-04 09:03:25 +01:00
```js
// Used to create docx files
var docx = require('docx');
2017-03-07 14:42:48 +00:00
// Create document
var doc = new docx.Document();
2016-07-04 09:03:25 +01:00
2017-03-13 01:11:11 +00:00
// Add some content in the document
var paragraph = new docx.Paragraph("Some cool text here.");
// Add more text into the paragraph if you wish
2017-03-14 10:38:05 +00:00
paragraph.addRun(new docx.TextRun('Lorem Ipsum Foo Bar'));
2017-03-13 01:11:11 +00:00
doc.addParagraph(paragraph);
2017-03-07 14:42:48 +00:00
// Used to export the file into a .docx file
2017-03-13 01:11:11 +00:00
var exporter = new docx.LocalPacker(doc);
// Or use the express packer to make the file downloadable.
2017-03-07 14:42:48 +00:00
// res is express' Response object
var exporter = new docx.ExpressPacker(doc, res);
2017-03-13 01:11:11 +00:00
exporter.pack('My First Document');
// done! A file called 'My First Document.docx'
// will be in your file system if you used LocalPacker
// Or it will start downloading if you are using Express
2016-07-04 09:03:25 +01:00
```
2017-03-13 01:21:26 +00:00
## Examples
Check [the Wiki](https://github.com/dolanmiu/docx/wiki/Examples) for examples.
2016-07-04 09:03:25 +01:00
# Contributing
Read the contribution guidelines [here](https://github.com/dolanmiu/docx/wiki/Contributing-Guidelines).
2017-03-14 10:48:24 +00:00
-----
2017-03-10 11:27:48 +00:00
2017-03-11 16:05:20 +00:00
Made with 💖
2017-03-10 11:27:48 +00:00
Huge thanks to [@felipeochoa](https://github.com/felipeochoa) for awesome contributions to this project
2016-07-19 19:02:44 +01:00
[npm-image]: https://badge.fury.io/js/docx.svg
[npm-url]: https://npmjs.org/package/docx
[travis-image]: https://travis-ci.org/dolanmiu/docx.svg?branch=master
2016-07-19 18:32:41 +01:00
[travis-url]: https://travis-ci.org/dolanmiu/docx
2016-07-19 19:02:44 +01:00
[daviddm-image]: https://david-dm.org/dolanmiu/docx.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/dolanmiu/docx
[snky-image]: https://snyk.io/test/github/dolanmiu/docx/badge.svg
2017-03-10 11:24:41 +00:00
[snky-url]: https://snyk.io/test/github/dolanmiu/docx
2017-03-13 12:30:22 +00:00
[gitter-image]: https://badges.gitter.im/dolanmiu/docx.svg
[gitter-url]: https://gitter.im/docx-lib/Lobby
2017-03-13 16:14:03 +00:00
[gemnasium-image]: https://gemnasium.com/badges/github.com/dolanmiu/docx.svg
[gemnasium-url]: https://gemnasium.com/github.com/dolanmiu/docx