title: Docx to pdf using pandoc in python
body: <p>So I a quite new to Python so it may be a silly question but i can't seem to find the solution anywhere.</p>
  <p>I have a django site I am running it locally on my machine just for development.
  on the site I want to convert a <code>docx</code> file to <code>pdf</code>. I want to use <code>pandoc</code> to do this. I know there are other methods such as online apis or the python modules such as &quot;docx2pdf&quot;. However i want to use <code>pandoc</code> for deployment reasons.</p>
  <p>I have installed <code>pandoc</code> on my terminal using <code>brew install pandoc</code>.
  so it should b installed correctly.</p>
  <p>In my django project i am doing:</p>
  <pre><code>import pypandoc
  import docx
  
  def making_a_doc_function(request):
      doc = docx.Document()
      doc.add_heading(&quot;MY DOCUMENT&quot;)
      doc.save('thisisdoc.docx')
      pypandoc.convert_file('thisisdoc.docx', 'docx', outputfile=&quot;thisisdoc.pdf&quot;)     
      pdf = open('thisisdoc.pdf', 'rb')
      response = FileResponse(pdf) 
  return response
  </code></pre>
  <p>The <code>docx</code> file get created no problem but it not <code>pdf</code> has been created. I am getting an error that says:</p>
  <p><code>Pandoc died with exitcode &quot;4&quot; during conversion: b'cannot produce pdf output from docx\n'</code></p>
  <p>Does anyone have any ideas?</p>