xjc 3 年之前
父节点
当前提交
d7cb9bf10c
共有 1 个文件被更改,包括 16 次插入18 次删除
  1. 16 18
      parsedocx.py

+ 16 - 18
parsedocx.py

@@ -7,7 +7,7 @@ import pythoncom
 from upload_to_oss import TedOSS
 import threading 
 import shutil
-from win32com.client.dynamic import Dispatch, ERRORS_BAD_CONTEXT
+#from win32com.client.dynamic import Dispatch, ERRORS_BAD_CONTEXT
 
 class DocxConverter(object):
     """
@@ -40,29 +40,27 @@ class DocxConverter(object):
         self.doc = self.word.Documents.Open(self.docpath)
         self.uuidhtml = str(uuid.uuid4())
         #html = os.path.join(os.path.dirname(self.docpath),self.uuidhtml+".html")
-        pdffile = os.path.join(os.path.dirname(self.docpath),self.uuidhtml+".pdf")
-        self.doc.SaveAs(pdffile,17)
         html = os.path.join(os.path.dirname(self.docpath),self.uuidhtml+".html")
+        self.doc.SaveAs(html,10)
         
-        from win32com.client.dynamic import Dispatch, ERRORS_BAD_CONTEXT
-        
-        AvDoc = Dispatch("AcroExch.AVDoc")
-        try:
-            if AvDoc.Open(pdffile,""):
-                pdDoc = AvDoc.GetPDDoc()
-                jsObject = pdDoc.GetJSObject()
-                jsObject.SaveAs(html,"com.adobe.acrobat.html")
-        except Exception as e:
-            import traceback
-            traceback.print_exc()
-            AvDoc.close(True)
-        finally:
-            AvDoc.Close(True)
+        #pdffile = os.path.join(os.path.dirname(self.docpath),self.uuidhtml+".pdf")
+        #self.doc.SaveAs(pdffile,17)
+        #AvDoc = Dispatch("AcroExch.AVDoc")
+        #try:
+        #    if AvDoc.Open(pdffile,""):
+        #        pdDoc = AvDoc.GetPDDoc()
+        #        jsObject = pdDoc.GetJSObject()
+        #        jsObject.SaveAs(html,"com.adobe.acrobat.html")
+        #except Exception as e:
+        #    import traceback
+        #    traceback.print_exc()
+        #    AvDoc.close(True)
+        #finally:
+        #    AvDoc.Close(True)
             
         self.doc.Close()
         self.word.Quit()
         os.remove(self.docpath)
-        #self.upload_imgfiles(self.uuidhtml)
         
         task = threading.Thread(target=self.upload_imgfiles,args=(self.uuidhtml,))
         task.start()