Skip to content

Commit

Permalink
docs(readme): add example for removing dumped images in cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Aug 5, 2024
1 parent 3b4336a commit 32fe58b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,30 @@ unRTF
});
```

### Removing images generated by UnRTF

As mentioned in the note block at the top of this README, the `noPictures` option does not remove images
when used with UnRTF < v0.20.4 and will write them to the current working directory.
To remove images generated by UnRTF it is recommended to use a globbing module such as [glob](https://www.npmjs.com/package/glob) in conjunction with the `node:fs/promises` module to find and remove them:

```js
import { unlink } from "node:fs/promises";
import { UnRTF } from "node-unrtf";
import { glob } from "glob";

const file = "test_resources/test_files/test-rtf-complex.rtf";
const unRtf = new UnRTF();
const options = {
outputHtml: true,
noPictures: true,
};

await unRtf.convert(file, options);

const files = await glob("*.{emf,wmf}");
await Promise.all(files.map((filed) => unlink(filed)));
```

## Contributing

Contributions are welcome, and any help is greatly appreciated!
Expand Down

0 comments on commit 32fe58b

Please sign in to comment.