Esempio n. 1
0
def convert_pdf_to_docx_with_abiword(input_path, out_path):
    run_with_timeout(["abiword", '--to=docx', input_path])
    filename_wo_extenstion, _ = os.path.splitext(input_path)
    temp_outfile = filename_wo_extenstion + ".docx"
    if not os.path.exists(temp_outfile):
        return 1
    shutil.move(temp_outfile, out_path)
 def convert_to_html_with_soffice(self, inp):
     run_with_timeout(
         [self.soffice, '--headless', '--convert-to', 'html', inp])
     filename_wo_extenstion, _ = os.path.splitext(inp)
     temp_outfile = filename_wo_extenstion + ".html"
     if not os.path.exists(temp_outfile):
         return None
     with open(temp_outfile, encoding="utf8") as inp:
         html = inp.read()
     os.unlink(temp_outfile)
     return html
 def convert_to_pdf(self, inp, out):
     if os.path.exists(out):
         os.unlink(out)
     run_with_timeout([
         self.soffice, '--headless', '--writer', '--convert-to', 'pdf', inp
     ])
     filename_wo_extenstion, _ = os.path.splitext(inp)
     temp_outfile = os.path.basename(filename_wo_extenstion + ".pdf")
     if not os.path.exists(temp_outfile):
         return 1
     shutil.move(temp_outfile, out)
 def run_soffice(self, inp, out):
     run_with_timeout([
         self.soffice, '--headless', '--writer', '--convert-to',
         'txt:Text (encoded):UTF8', inp
     ])
     filename_wo_extenstion, _ = os.path.splitext(inp)
     temp_outfile = filename_wo_extenstion + ".txt"
     if not os.path.exists(temp_outfile):
         return 1
     shutil.move(temp_outfile, out)
     return 0
 def run_calibre(self, inp, out):
     return run_with_timeout([self.calibre, inp, out])