【发布时间】:2021-08-07 20:31:07
【问题描述】:
我正在使用 Pandoc v1.12.2.1 将 html 转换为 docx。它通常可以工作,但我试图让它在docx 模板文件中读取,所以我可以告诉它使用 Arial 作为字体并将所有标题设为黑色(而不是蓝色,因为它们在瞬间)。
模板文件在
/path/to/my/project/public/pandoc/templates/reference.docx
我这样称呼 Pandoc:
pandoc --data-dir /path/to/my/project/public/pandoc --template reference.docx -s "$input" -o "$output"
$input 和 $output 分别是我正在读取的 html 文件和生成的 docx 文件的目标位置。
它会生成一个docx 文件,但它没有考虑我的模板 - 它看起来与我不使用模板文件时相同。我认为它正在读取reference.docx 文件,因为如果我更改文件名,它会抱怨它不存在。
为了生成模板,我按照 [https://pandoc.org/MANUAL.html#option--reference-doc][1] 上的说明获取了由 Pandoc 生成的 docx 文件,编辑样式设置,然后保存。
我已将模板文件放在 [此处][2] 以防任何人发现其中有任何问题。
我正在尝试在 Ubuntu 14.04 中使用 LibreOffice 执行此操作,我想知道这是否与它无法正常工作有关?我需要在 Windows 中的 Microsoft Word 中编辑模板吗?
感谢任何建议。
编辑 - 我也试过这个:
pandoc "$input" -s --reference-docx /path/to/my/project/public/pandoc/templates/reference.docx -o "$output"
``
and have the same result: it doesn't seem to use the styles, but it will complain if I change the filename, suggesting that it is reading the doc.
[1]: https://pandoc.org/MANUAL.html#option--reference-doc
[2]: https://www.dropbox.com/s/e4dl9avue1i7vkr/reference.docx?dl=1
【问题讨论】:
标签: docx pandoc file-conversion