在osx上批量转换.py(文本文件)到.pdf

时间:2014-03-01 19:50:15

标签: python pdf text batch-processing

我教授python课程,并提交了大量为考试提交的.py文件。我想将所有这些转换为pdf,以便我可以在我的ipad上的IAnnotate中打开它们,标记它们并将它们返回给学生。如何在批处理模式下进行这样的转换?

1 个答案:

答案 0 :(得分:6)

试图小牛队:

#!/bin/bash
for file in *.py; do
    textutil -convert rtf -font 'Courier New' -fontsize 9 ${file} -output ${file}.rtf
    cupsfilter -D ${file}.rtf > ${file}.pdf
done

生成的文件将命名为*.py.pdf