AvDoc

作者: 月夜星空下 | 来源:发表于2021-05-31 15:42 被阅读0次
    import os
    import winerror
    from win32com.client.dynamic import Dispatch, ERRORS_BAD_CONTEXT
    
    ERRORS_BAD_CONTEXT.append(winerror.E_NOTIMPL)
    
    my_dir = r"C:\\path\\to\\example\\"
    my_pdf = "example.PDF"
    
    os.chdir(my_dir)
    src = os.path.abspath(my_pdf)
    
    try:
        AvDoc = Dispatch("AcroExch.AVDoc")
    
        if AvDoc.Open(src, ""):
            pdDoc = AvDoc.GetPDDoc()
            jsObject = pdDoc.GetJSObject()
            jsObject.SaveAs(os.path.join(my_dir, 'output_example.xml'), "com.adobe.acrobat.xml-1-00")
    
    except Exception as e:
        print(str(e))
    
    finally:
        AvDoc.Close(True)
    
        jsObject = None
        pdDoc = None
        AvDoc = None
    

    相关文章

      网友评论

          本文标题:AvDoc

          本文链接:https://www.haomeiwen.com/subject/nyjbsltx.html