No description
Find a file
2020-02-08 14:12:23 +08:00
.github/workflows Update action.yml 2019-12-27 11:48:56 +08:00
src Update utils.nim 2020-01-05 14:49:06 +08:00
tests clean 2019-12-28 15:12:12 +08:00
docx.nimble Update docx.nimble 2020-01-05 14:51:03 +08:00
LICENSE init 2019-12-14 17:22:07 +08:00
README.md Update README.md 2020-02-08 14:12:23 +08:00

docx nimble

A dead simple docx reader.

Read pure text from docx written by Nim.

Usage

Keep only newline information.

import docx


echo parseDocument("test.docx")
for line in docLines("test.docx"):
  echo line

Output:

长记曾携手处,千树压、西湖寒碧。
I strove with none.
For none was worth my strife;
Nature I lovd,
And next to Nature, Art;
I warmd both hands before the fire of life;
It sinks,
and I am ready to depart.
仰天大笑出门去,我辈岂是蓬蒿人。

Only parse pure text.

import docx


echo parsePureText("test.docx")

Output:

长记曾携手处千树压、西湖寒碧。I strove with none.For none was worth my strife;Nature I lovd,And next to Nature, Art;I warmd both hands before the fire of life;It sinks,and I am ready to depart.仰天大笑出门去,我辈岂是蓬蒿人。

Extract Picture from docx

let tmpDir = getTempDir()
if existsDir(tmpDir / "generate"):
  removeDir(tmpDir / "generate")
extractPicture("tests/test_pic.docx", tmpDir / "generate")
assert existsFile(tmpDir / "generate/image1.jpeg")