code: def write_pdf(self, html):
          
          try:
              f = tempfile.NamedTemporaryFile(delete=False, suffix='.html')
              f.write(html.encode('utf_8', 'xmlcharrefreplace'))
              f.close()
          except Exception:
              raise IOError(u"Unable to create temporary file, aborting")
  
          dummy_fh = open(os.path.devnull, 'w')
  
          try:
              command = ["prince", f.name, "-o", self.destination_file]
  
              Popen(command, stderr=dummy_fh).communicate()
          except Exception:
              raise EnvironmentError(u"Unable to generate PDF file using "
                                      "prince. Is it installed and available?")
          finally:
              dummy_fh.close()
docs: Tries to write a PDF export from the command line using Prince if
              available.