Skip to content

Commit 62f1012

Browse files
committed
Update docs for new Packer methods
To cover #2920
1 parent a887927 commit 62f1012

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

docs/usage/packers.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> Packers are the way in which `docx` turns your code into `.docx` format. It is completely decoupled from the `docx.Document`.
44
5-
Packers works in both a node and browser environment (Angular etc). Now, the packer returns a `Buffer`, `Blob`, `string`, `base64 string`, or `Stream`. 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.
5+
Packers works in both a node and browser environment (Angular etc). Now, the packer returns a `Buffer`, `Blob`, `string`, `base64 string`, `ArrayBuffer`, or `Stream`. 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.
66

77
### Export as Buffer
88

@@ -41,6 +41,16 @@ Packer.toBlob(doc).then((blob) => {
4141
});
4242
```
4343

44+
### Export as ArrayBuffer
45+
46+
This may be useful when working in a Node.js worker.
47+
48+
```ts
49+
Packer.toArrayBuffer(doc).then((arrayBuffer) => {
50+
port.postMessage(arrayBuffer, [arrayBuffer]);
51+
});
52+
```
53+
4454
### Export as a Stream
4555

4656
```ts
@@ -63,3 +73,13 @@ Packer.toString(doc, true, overrides).then((string) => {
6373
console.log(string);
6474
});
6575
```
76+
77+
### Export to arbitrary formats
78+
79+
You can also use the lower-level `Packer.pack` method to export to any specified type.
80+
81+
```ts
82+
Packer.pack(doc, 'string').then((string) => {
83+
console.log(string);
84+
});
85+
```

0 commit comments

Comments
 (0)