如何使用adobeacrobat及其公开的COM对象以编程方式将多页tiff拆分为单个页面?

2024-04-25 05:21:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用adobeacrobat公开的COM对象以编程方式(使用Python)将多页tiff拆分为单个页面。在

我写这篇文章是为了回答我自己的问题,以便提出一个可行的答案,因为我没有发现任何人在某某或任何其他论坛上这样做。在

请让我知道你对我的解决方案有什么看法,并随时离开你这样做的方式。在


Tags: 对象答案com编程方式页面解决方案论坛
1条回答
网友
1楼 · 发布于 2024-04-25 05:21:27

有一种方法:

from win32com.client import Dispatch

def acrobat_split(f_path,f_name,f_ext):


    # Connect to Adobe Acrobat.
    avDoc = Dispatch("AcroExch.AVDoc")

    # Open the input file (as a pdf).
    src = f_path+'\\'+f_name+f_ext
    avDoc.Open(src,src)


    pdDoc = avDoc.GetPDDoc()
    page_ct = pdDoc.GetNumPages()

    # Set dst.
    dst = f_path+'\\'+f_name+PAGE_DIV+".tif"

    jsObject = pdDoc.getJSObject()

    #Here you can save as many other types by using, for instance: "com.adobe.acrobat.xml"
    jsObject.saveAs(dst,"com.adobe.acrobat.tiff")

    pdDoc.Close()
    del pdDoc

相关问题 更多 >