【发布时间】:2017-09-13 12:53:56
【问题描述】:
我想知道将路径中的 txt 文件批量转换为 PDF 的最简单方法是什么?
我在 Python https://github.com/baruchel/txt2pdf 中对此进行了研究 但我似乎无法在导入后在终端中调用 txt2pdf。
还有其他建议吗?
类似:
text_file = open(filename, 'r')
i = 0
for item in text_file:
i += 1
f = open("c:\\workspace\\{0}.txt".format(i), 'w')
txt2pdf convert (whatever goes here)
if i == 7:
break
也使用 ReportLab 尝试过
def hello(c):
ic = 0
c = open("c:\\workspace\\simple\\{0}.txt".format(ic), 'w')
for item in c:
ic += 1
c = canvas.Canvas("c:\\workspace\\simple\\{0}.pdf".format(ic))
hello(c)
c.showPage()
c.save()
if ic == 7:
break
【问题讨论】:
-
你的
text2pdf.py在哪里?