https://github.com/ringabout/docx
read pure text from docx written by Nim.
https://github.com/ringabout/docx
Last synced: about 1 year ago
JSON representation
read pure text from docx written by Nim.
- Host: GitHub
- URL: https://github.com/ringabout/docx
- Owner: ringabout
- License: mit
- Created: 2019-12-14T08:56:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-08T06:12:24.000Z (over 6 years ago)
- Last Synced: 2024-10-14T15:03:53.990Z (over 1 year ago)
- Language: Nim
- Homepage:
- Size: 7.83 MB
- Stars: 16
- Watchers: 6
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# docx [](https://github.com/yglukhov/nimble-tag)
A dead simple docx reader.
Read pure text from docx written by Nim.
## Usage
### Keep only newline information.
```nim
import docx
echo parseDocument("test.docx")
for line in docLines("test.docx"):
echo line
```
Output:
```text
长记曾携手处,千树压、西湖寒碧。
I strove with none.
For none was worth my strife;
Nature I lov’d,
And next to Nature, Art;
I warm’d both hands before the fire of life;
It sinks,
and I am ready to depart.
仰天大笑出门去,我辈岂是蓬蒿人。
```
### Only parse pure text.
```nim
import docx
echo parsePureText("test.docx")
```
Output:
```text
长记曾携手处,千树压、西湖寒碧。I strove with none.For none was worth my strife;Nature I lov’d,And next to Nature, Art;I warm’d both hands before the fire of life;It sinks,and I am ready to depart.仰天大笑出门去,我辈岂是蓬蒿人。
```
### Extract Picture from docx
```nim
let tmpDir = getTempDir()
if existsDir(tmpDir / "generate"):
removeDir(tmpDir / "generate")
extractPicture("tests/test_pic.docx", tmpDir / "generate")
assert existsFile(tmpDir / "generate/image1.jpeg")
```