Solved

PDF Createobject no longer working

Posted on 2006-06-14
30
4,476 Views
Last Modified: 2013-12-18
Hello Experts
I have this code in my lotusscript to print PDF files, but this no longer seems to work, it fails in the second line with "Cannot create automation Object", HERE f is the file name tha tis passed as a parameter. I searched the forums , but couldn't get the relevant object, any ideas .....

      Dim AcroApp As Variant,PDDoc,AVDoc
      Set AcroApp = CreateObject("AcroExch.App")
      Set PDDoc = CreateObject("AcroExch.PDDOC")
      Set AVDoc = CreateObject("AcroExch.AVDoc")
      Call AVDoc.Open(f, "")
      Set PDDoc = AVDoc.getpdDoc
      
      iNumPages = PDDoc.GetNumPages
      
      Call AVDoc.PrintPagesSilent(0, iNumPages-1, 1, True, True)
      PrintPDF = True
0
Comment
Question by:p_partha
  • 13
  • 11
  • 3
  • +1
30 Comments
 
LVL 22

Expert Comment

by:mbonaci
ID: 16903401
Hi p_partha,
do you have Acrobat destiller installed (if yes, reinstall)?

Hope this helps,
Marko
0
 
LVL 14

Author Comment

by:p_partha
ID: 16903472
Hi Marko
Am not sure what's the destiller is , But when i see in my machine it's Adobe Reader 7.0 version 7.0.5

Thanks
Partha
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16903482
They do something different over here:
    http://diaryproducts.net/for/programmer/adobe_acrobat_pdf_scripting_visualbasic_javascript

    Set app = CreateObject("AcroExch.App")
   
    Set avDoc = app.GetActiveDoc ' get the logical doc
    Set pdDoc = avDoc.GetPDDoc   ' get the physical doc
    Set jso = pdDoc.GetJSObject  ' get the bridge
    docs = jso.app.activeDocs    ' get array of active docs

And this link:
    http://www.experts-exchange.com/Web/Graphics/Adobe_Acrobat/Q_20932073.html

I assume (ahem) that there's a problem with the registry. Can you install Adobe again??
0
 
LVL 14

Author Comment

by:p_partha
ID: 16903529
Bro,
it happens in all the machines, not just mine, second it fails in the first line  :   Set app = CreateObject("AcroExch.App") , so it's not able to instantiate this , so i thought probably for the newer versions, this object name has changed

partha
0
 
LVL 14

Author Comment

by:p_partha
ID: 16903536
and oh yeah, the end users simply wrote a email "YOUR CODE DOESN'T WORK " (in CAPS, BOLD) :))

Partha
0
 
LVL 22

Assisted Solution

by:mbonaci
mbonaci earned 50 total points
ID: 16903709
p_partha,
if you have it registered you should be able to see it in this dialog:
    in Designer, on form, choose from toolbar Insert - Object

If it isn't there you'll have to reinstall the application that registeres it to the OS or in the Insert Object dialog choose Control in option button and click on "Add control to list" and find your DLL or OCX (probably in Program files, where Adobe is installed)

Hope this helps,
Marko
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16903743
Then what's new on all your machines? Ah, I know, it's Wednesday June 14...

Nonsense of course. What's changed in your environment? New Domino server release? Or new Notes? Or new Adobe, automatically installed?
0
 
LVL 14

Author Comment

by:p_partha
ID: 16903821
I believe it's the Acrobat that got installed, dont' know when though, but it's a low profile application where they print the attachments automatically by selecting the documents,

Marko,
I went into my form and i did find the Adobe Acrobat 7.0 Document, and in the Control I find Adobe ACrobat 7.0 Browser Document, using this can i create and print any of the files, even if it's changing the code, i have no issues, and it should be silent printing (no dialog boxes )

Partha
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16904318
Acrobat that got installed << yes, only Acrobet Professional has these objects:

 Set AcroApp = CreateObject("AcroExch.App")
     Set PDDoc = CreateObject("AcroExch.PDDOC")
     Set AVDoc = CreateObject("AcroExch.AVDoc")


The reader has no ability to print, other than what it has open, so there are no com objects for Acrobat Reader.   I had that happen in my last place of work (actually, I did it a few times) I installed Reader when I should have installed Acrobat.   Significant difference in price and capability.

Acrobat Reader does not.
0
 
LVL 14

Author Comment

by:p_partha
ID: 16905172
THanks marilyng

Is there a demo/limited professional version i can download free just to see whether that solves the problem? Then i can go ahead and convince the client

Thanks
partha
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16905419
yeah, you can go to Adobe.com and download the trial for 30 days.  I just checked the copy on my machine for the particular objects (Acrobat Professional V7) and they are in the COM/OLE/ActiveX.  I know they don't appear in Reader, because I just recently debugged this problem.  The only other alternative is to revise the print command to use another PDF generator, like pdf995 (really easy)  You can call the printer using windows scripting language to set the default printer and then print direct from Notes.

The only problem I had with this was in windows 2000 and Notes 5 << these wouldn't change the default printer without your sending the announcement to the registry. And if the client can't write to the registery..well, you get errors.
0
 
LVL 14

Author Comment

by:p_partha
ID: 16906428
Thanks Marilyng, i installed the trial version and the problem seem to have gone away, i have asked my IT to install the professional version in one of the client's machine, just to verify

Thanks all
Partha
0
 
LVL 14

Author Comment

by:p_partha
ID: 16987086
Guys
After the upgrade to the professional version,  the code doesn't seem to work: Here is the code, i am not sure what else i have to do :(

Function PrintPDF(f$) As Integer
      Dim AcroApp
      Dim AVDoc
      Dim PDDOc
      Dim iNumPages
      Set AcroApp = CreateObject("AcroExch.App")
      Set PDDoc = CreateObject("AcroExch.PDDOC")
      Acroapp.Show
      On Error Goto ppdfError
      If Isempty(AcroApp) Then Error 999, "Word Application Not Started"
      Set AVDoc = CreateObject("AcroExch.AVDoc")
      
      returnvals=  AVDoc.Open("c:\temp\FY06LICUS.pdf", "")
      
      Set PDDoc = AVDoc.GetPDDoc
      
      iNumPages = PDDoc.GetNumPages
      
      retval =    AVDoc.PrintPages(1, 1, 2, False, False)
      Msgbox retval
      PrintPDF = True
ExitFunction:
      If Not Isempty(AVDoc) Then Call AVDoc.Close(True)
      Exit Function
ppdfError:
      Msgbox "Error Occured and error is " & Error
      PrintPDF = False
      Resume ExitFunction
End Function

any inputs appreciated

Thanks
0
 
LVL 46

Assisted Solution

by:Sjef Bosman
Sjef Bosman earned 50 total points
ID: 16988177
Just a question, after reading
    http://diaryproducts.net/for/programmer/adobe_acrobat_pdf_scripting_visualbasic_javascript

why do you create a new object PDDoc and 1 second later you set it to AVDoc.getpdDoc??
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 18

Expert Comment

by:marilyng
ID: 16988832
Try:


set AcrApp = CreateObject("AcroExch.App")
set PDDOC= CreateObject("AcroExch.PDDoc")
PDDOC.Open("c:\temp\FY06LICUS.pdf")
iNumPages = PDDoc.GetNumPages
     
retval =    PDDOC.PrintPages(1, 1, 2, False, False)
Msgbox retval
PrintPDF = True

PDDOC.Close()

-----------
Look here for examples: http://www.planetpdf.com
0
 
LVL 14

Author Comment

by:p_partha
ID: 17012854
Marilyng
Did you try that code, actually it throws out a error on the getNUmPages, it looks like PDDOC is not set, any ideas

Partha
0
 
LVL 18

Expert Comment

by:marilyng
ID: 17015347
Other than using the javascript.print method?

http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJSGuide.pdf

PDDoc is an acrobat professional object. So it won't be available unless professional is installed.  Trying to fiddle with the javascript print ... and the print silent.  So, if you get a handle on a pdf document in javascript, and call the acrobate object, then the printparams object is available to print silently via javascript.
0
 
LVL 14

Author Comment

by:p_partha
ID: 17017567
Marilyng,
I have do this in Lotusscript, as it's on the client side, but can somebody confirm the code and chekc whether it's working

Partha
0
 
LVL 18

Expert Comment

by:marilyng
ID: 17017844
Hee, hee... where I have full acrobat and objects, I don't have notes.. :)  Have to download a test of full acrobat.

I have a similar problem printing pdf documents from another application, so I have to solve this, too, over the weekend.  Will get back to you when I have an answer,
0
 
LVL 14

Author Comment

by:p_partha
ID: 17017880
thx marilyng, much appreciated,

Sjef bro, i will look into your option also and keep you posted, once i come with a viable answer...

Partha
0
 
LVL 18

Accepted Solution

by:
marilyng earned 150 total points
ID: 17044266
This works:

Sub printPDF()
  'Run Adobe Acrobat Writer as COM-server
  'On Error Resume Next
   strFilePath = "c:\printtest.pdf"
    Dim AcroApp
     Dim AVDoc
     Dim PDDOc
     Dim iNumPages
     Set AcroApp = CreateObject("AcroExch.App")
     Set AVDoc = CreateObject("AcroExch.AVDoc")
     Set PDDOc = CreateObject("AcroExch.PDDOC")
     AcroApp.Show
     On Error GoTo ppdfError
     If IsEmpty(AcroApp) Then Error 999
     
     returnvals = AVDoc.Open(strFilePath, "PrintPDF")
     Set PDDOc = AVDoc.GetPDDoc
     iNumPages = PDDOc.GetNumPages
     
     Call AVDoc.PrintPagesSilent(0, iNumPages, 2, False, False)
     
ExitFunction:
     If Not IsEmpty(AVDoc) Then Call AVDoc.Close(True)
     Exit Sub
ppdfError:
     MsgBox "Error Occured and error is " & Error
     
     Resume Next

End Sub

I think it is the retval on the AVDoc.PrintPagesSilent, that is causing the problem
0
 
LVL 18

Expert Comment

by:marilyng
ID: 17044446
Also, I added this to check for any open documents in Acrobat and close them:
If Not IsEmpty(AVDoc) Then Call AVDoc.Close(True)
     Dim openDocs As Long
     openDocs = AcroApp.GetNumAVDocs()
     If openDocs < 1 Then
     Dim retval As Long
     
     retval = AcroApp.closealldocs
       If retval < 0 Then
       Call AcroApp.exit
       Else
        MsgBox "Sorry, was unable to close Acrobat, please remember to close the application"
      End If
     End If
     
     Exit Sub
0
 
LVL 14

Author Comment

by:p_partha
ID: 17044907
Marilyng
am not that lucky it fails in the line :Set PDDOc = AVDoc.GetPDDoc

it says automation object not found, may be it might be due to the trial version i have. i am not sure though.. but it prints at the end as there is a resume next, i will experiment some more,

Thanks for the efforts
Partha
0
 
LVL 18

Expert Comment

by:marilyng
ID: 17045669
You need AVDoc to get the print method.  PDDoc just grabs the back end document to count the number of pages, but the AVDoc is what contains the print method.  And the PrintAllSilent needs a number of pages to print, else the print dialog box appears.

I think what I ended up doing was making a list of the print methods and on error resume next to figure out which one worked, since they are all supposed to work :)
0
 
LVL 18

Expert Comment

by:marilyng
ID: 17045680
This was tested on Acrobat Professional 7.0 - and I ran it from excel. :)
0
 
LVL 18

Expert Comment

by:marilyng
ID: 17045691
Is the PDDoc object listed in the Lotus OLE Library?  Under Acrobat 3.0 type library.
0
 
LVL 14

Author Comment

by:p_partha
ID: 17168081
Sorry to have not got back... I am extremely busy with one another project. For now I am just splitting the points with the lion's share going to marilyng

Partha
0
 
LVL 18

Expert Comment

by:marilyng
ID: 17170023
Thanks!
0
 
LVL 14

Author Comment

by:p_partha
ID: 17170233
Marilyng,
If you and sjef will be kind enough to see the other open question of mine

Regards
Partha
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now