如何自动校对PDF和测试他们的错误?

时间:2016-06-29 16:38:31

标签: regex makefile grep automated-tests pdftotext

使用makefile通过pandoc从LaTeX或MarkDown生成PDF时,如何自动检查生成的PDF是否有错误,代码/文本编辑器可能找不到?

1 个答案:

答案 0 :(得分:1)

如果错误已知&可以是注册表(例如duplicate words),在文件中逐行写下这些内容(例如,称为CHECKS)。然后,在makefile中使用以下命令:

pdftotext file.pdf - | \  # sends content of PDF to stdout & pipes it into...
grep \
    --color \             # highlights errors in stdout
    --ignore-case \
    --extended-regexp \
    --file=CHECKS         # contains the error patterns

附加到PDF的make目标,这个IMHO有助于防止特别重复的错误。

PS:从German blog post总结。现实生活example here