Deploy dolanmiu/docx to github.com/dolanmiu/docx.git:gh-pages

This commit is contained in:
Deployment Bot (from Travis CI)
2018-08-21 21:07:49 +00:00
parent d1c499e2aa
commit 420dba07a6
334 changed files with 2587 additions and 6467 deletions

View File

@ -19,8 +19,8 @@ doc.Footer.createParagraph("Footer text");
Even add images:
```js
doc.Header.createImage([PATH_TO_YOUR_IMAGE]);
doc.Footer.createImage([PATH_TO_YOUR_IMAGE]);
doc.Header.createImage([BUFFER_OF_YOUR_IMAGE]);
doc.Footer.createImage([BUFFER_OF_YOUR_IMAGE]);
```
Refer to `demo8.js` for more information

View File

@ -7,7 +7,7 @@ Adding images is very simple
Simply call the `createImage` method:
```js
const image = doc.createImage([PATH_TO_YOUR_IMAGE]);
const image = doc.createImage([BUFFER_OF_YOUR_IMAGE]);
```
`docx` supports `jpeg`, `jpg`, `bmp`, `gif` and `png`
@ -43,7 +43,7 @@ interface DrawingOptions {
can be passed when creating `PictureRun()` for example:
```js
const imageData = document.createImageData(filename, buffer, 903, 1149);
const imageData = document.createImage(buffer, 903, 1149);
new docx.PictureRun(imageData, {
position: docx.PlacementPosition.FLOATING,

View File

@ -2,7 +2,48 @@
> Packers are the way in which `docx` turns your code into `.docx` format. It is completely decoupled from the `docx.Document`.
## File System Packer
## Version 4
Packers in `version 4` and above are now one single `Packer`. It works in both a node and browser environment (Angular etc). Now, the packer returns a `Buffer`, `Blob` or `base64 string`. It is up to you to take that and persist it with node's `fs`, send it down as a downloadable file, or anything else you wish. As of version 4, this library will not have options to export to PDF.
### Export as Buffer
This will return a NodeJS `Buffer`. If this is used in the browser, it will return a `UInt8Array` instead.
```js
const packer = new docx.Packer();
packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});
```
### Export as a `base64` string
```js
const packer = new docx.Packer();
packer.toBase64String(doc).then((string) => {
console.log(string);
});
```
### Export as Blob
This is useful if you want to send it as an downloadable in a browser environment.
```js
const packer = new docx.Packer();
packer.toBlob(doc).then((blob) => {
// saveAs from FileSaver will download the file
saveAs(blob, "example.docx");
});
```
## Version 3 and below
### File System Packer
```js
const docx = require("docx");
@ -13,7 +54,7 @@ exporter.pack("My Document");
// Word Document is in file system
```
## Buffer Packer
### Buffer Packer
```js
const docx = require("docx");
@ -23,7 +64,7 @@ const exporter = new docx.BufferPacker(doc);
const buffer = exporter.pack();
```
## Stream Packer
### Stream Packer
Creates a `node` `Readable` stream
@ -35,7 +76,7 @@ const exporter = new docx.StreamPacker(doc);
const stream = exporter.pack();
```
## Express Packer
### Express Packer
The old express packer is now deprecated and may disappear soon, so you should upgrade.
@ -56,13 +97,13 @@ const exporter = new docx.StreamPacker(doc);
const stream = exporter.pack();
// Express' response object
res.attachment('yourfile.xlsx');
res.attachment("yourfile.xlsx");
stream.pipe(res);
```
where `res` is the response object obtained through the Express router. It is that simple. The file will begin downloading in the browser.
## PDF Exporting
### PDF Exporting
You can export your word document as a PDF file like so:
@ -74,7 +115,3 @@ exporter.packPdf("My Document");
const exporter = new docx.ExpressPacker(doc, res);
exporter.packPdf("My Document");
```
## Browser based docx exporting
It is on the bucket list. It has been requested by a few, and work is already on it