title: Python convert txt file to pdf
body: <p>I was wondering what would be simplest way to convert txt files in path batch convert to PDF?</p>
  
  <p>I've looked into this in Python <a href="https://github.com/baruchel/txt2pdf" rel="nofollow noreferrer">https://github.com/baruchel/txt2pdf</a>
  but I can't seem to call txt2pdf in terminal after importing it.</p>
  
  <p>Any other suggestions?</p>
  
  <p>Something like:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>also tried this using ReportLab</p>
  
  <pre><code>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
  </code></pre>