How do I programmatically split a multi-page tiff into single pages using Adobe Acrobat and it's exposed COM Objects?

StackOverflow https://stackoverflow.com/questions/22099680

Question

I want to programmatically (using Python) split a multi-page tiff into single pages using Adobe Acrobat's exposed COM Objects.

I am writing this in order to answer my own question in order to put a viable answer out there, as I did not find anyone doing this on SO or any other forum.

Please, let me know what you think about my solution and feel free to leave your way of doing this.

No correct solution

OTHER TIPS

Here is one way:

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top