Sign in to follow this  
Followers 0
mozart90

Need help with com Object

3 posts in this topic

Hi

I wrote the following code. It converts just2 pdf files into a new one. (It's part of a bigger project)

Everthing worked fine - until the Acrobat version changed from 6 to 7.

My problem is I got no COM Error - but the object does not work ...

PDFMerge("c:\tmpp\1.pdf","c:\tmpp\2.pdf","c:\tmpp\out.pdf")   


func PDFMerge($File1, $File2, $Fileout)  

; ---------------------------------------
; File1 first file 
; File2 2nd file is inserted after
; Fileout is the new filename 
;
; returns  1 on success
; returns -1 Error insert Pages 
; returns -2 Error Object Create
;----------------------------------------
    
    $SourcePDF = ObjCreate("AcroExch.PDDoc")
    
    if not IsObj($SourcePDF) then 
        msgbox(0,"dbg1", "Err1") 
        return -2
    endif   
    
    $b = $SourcePDF.Open($file1)
    msgbox(0,"b", $B) 
    $TargetPDF = ObjCreate("AcroExch.PDDoc")
    
    if not IsObj($TargetPDF) then 
        msgbox(0,"dbg2", "Err2") 
        return -2
    endif 
    
    $c = $TargetPDF.Open($file2)
    msgbox(0,"c", $c) 

    $intSourcePgs = $SourcePDF.GetNumPages
    msgbox(0,"num",$intSourcePgs) 
    $intInsertPgs = $TargetPDF.GetNumPages
    if not $SourcePDF.InsertPages($intSourcePgs-1, $TargetPDF, 0, $intInsertPgs, False) = -1  then 

        $SourcePDF.Close
        $TargetPDF.Close
        $SourcePDF=""
        $TargetPDF=""
        return -1 
    endif 
    $b = $SourcePDF.Save(1, $fileout)
    $SourcePDF.Close
    $TargetPDF.Close
    $SourcePDF=""
    $TargetPDF=""
    return 1
endfunc

greetings mozart90

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What is your value of $SourcePDF after this line? Wonder if the ObjCreate string should change after the acrobate update?

$SourcePDF = ObjCreate("AcroExch.PDDoc")
Edited by Uten

Share this post


Link to post
Share on other sites

What is your value of $SourcePDF after this line? Wonder if the ObjCreate string should change after the acrobate update?

$SourcePDF = ObjCreate("AcroExch.PDDoc")

... year thought about a changed object string too. but on the other hand by checking the $SourcePDF it seems to an object. I do not get an error with IsObj($SourcePDF)!

So I'm a little confused :whistle:

greetings mozart90

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0