You can use the AcroPDF library to display a PDF document in applications using simplified browser controls. In this case, the PDF document is treated as an ActiveX document, and the interface is available in Acrobat Reader.
The only requirement for using the OLE objects made available by Acrobat is to have the product installed on your system and the appropriate type library file included in the project references for your project. The Acrobat type library file is named Acrobat.tlb. This file is included in the InterAppCommunicationSupportHeaders folder in the SDK. Once you have the type library file included in your project, you can use the object browser to browse the OLE objects.
The CAcro classes are defined in the Acrobat type library acrobat.tlb. The OLEView tool in Visual Studio allows you to browse registered type libraries. Use acrobat.tlb when defining OLE automation for a project in Microsoft Visual C++. The files acrobat.h and acrobat.cpp are included in the Acrobat SDK, and implement a type-safe wrapper to the Acrobat automation server.
This procedure adds a reference to the Acrobat type library so that you can access the Acrobat automation APIs, including JSObject, in Visual Basic. Do this before using the JSObject interface, as in the examples that follow.
You may have a few questions after studying the code. For example, why is jso declared as an Object, while gApp and gPDDoc are declared as types found in the Acrobat type library? Is there a real type for JSObject ?
JSObject always returns values as Variants. This includes property gets as well as return values from method calls. An empty Variant is used when a null return value is expected. When JSObject returns an array, each element in the array is a Variant. To determine the actual data type of a Variant, use the utility functions IsArray, IsNumeric, IsEmpty, IsObject, and VarType from the Information module of the Visual Basic for Applications (VBA) library.
Judging from the responses to date, apparently, many of us cannot help you.VBScript's file system object has a difficult time with anything other than
text files. You will either need to determine the details of the format and
write your own interface, or find a document object model for pdf's.
Unfortunately, googling ["document object model" "portable document format"]
seems to find information about document object models for htnl, dhtml,
word, and etc, all presented in pdf format. I checked the adobe site, and
could not find anything helpful there, other than adobe acrobat itself. It
could be that the full acrobat package provides what you need, but possibly
not./Al
The Acrobat controls do not provide a shell of their own, but must be
hosted by an application, like IE. Gunter Born wrote about this years
ago. His web site, WSH Bazaar, is no longer maintained, but is still
out there. See: -homepage.de/gborn/WSHBazaar/WSHBazaar.htm.
In the Newsletter #5, he presents the basics of hosting the Acrobat
Reader ActiveX in IE and does a lot of manipulations. Unfortunately,
he does not cover the method you discuss and some of the supporting
files are missing. Further, if the input arguments must be typed as
Long, they cannot by implemented in script, since all variables in
script are of type Variant.I looked at the methods that are exposed in all of the Acrobat ActiveX
libraries on my machine and I cannot find a reference to a FindText
method. I did this with show hidden objects selected. Where did you
find a reference to this method?
Yes, I later found the AcroAVDoc class in the dll you cite. However,
I could not instantiate that class in a VBS script. It is not
registered as a class so that CreateObject cannot instatiate it. My
attempts to use GetObject to do it from a reference to the type
library dll at "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.dll"
also failed, though that is the library that is linked in an Office
object browser, like in Excel, to expose the class.The 'if all else fails' approach to linking to such a class is to use
an tag in a WSH, HTA or HTML document, but that requires a
ClassID, which I failed to track down in the registry after 30 minutes
(and gave up).I suppose an Excel.Application could be used to instantiate it from
script, but it is clear that Adobe does not really want people to
access their code except through their Reader. As Al Dunbar suggested
in another post in this thread, "In fact, isn't one of the reasons for
FAQ184-2483 - answering getting answered.Chris
PDFcommandertm.com
PDFcommandertm.co.uk
RE: VFP parameter to control the PDF page displayed in Reader ChrisRChamberlain (Programmer)29 Jul 04 03:33Sammybobo
ApologiesQuote:But once the pdf had been distilled into a pdf, it would always start at page nshould be Quote:But once the postscript file had been distilled into a pdf, it would always start at page n FAQ184-2483 - answering getting answered.Chris
PDFcommandertm.com
PDFcommandertm.co.uk
RE: VFP parameter to control the PDF page displayed in Reader Mike Gagnon (Programmer)29 Jul 04 06:12Sammybobo
This would require the use of Adobe Acrobat (The full version) not just the reader. Included in it there is a module called Adobe Acrobat Document viewer (acroExch.AVDoc) that you can control to show a document at a specific page. Mike Gagnon
If you want to get the best response to a question, please check out FAQ184-2483 first. RE: VFP parameter to control the PDF page displayed in Reader Sammybobo (Programmer)(OP)29 Jul 04 12:19Thanks, guys!
Sammybobo RE: VFP parameter to control the PDF page displayed in Reader terosoft (Programmer)29 Jul 04 17:23Look at your ActiveX controls list, you should have one control called "Adobe Acrobat Control for ActiveX". If it's not there download and install Acrobat Reader 6.
I couldn't find a "goto page #" method but it has "gotoNextPage" and "gotoPreviousPage" methods that should be enough for you. Gerardo Czajkowski
0 RE: VFP parameter to control the PDF page displayed in Reader RickSchummer (Programmer)1 Aug 04 12:51Chris,
There is an ActiveX interface to Acrobat. You can use the Object Browser in VFP to look around. I use it all the time.
Unfortunately I could not figure out how to navigate to a specific page in the time I tried to do it.
_RAS
www.whitelightcomputing.com
VFP MVP RE: VFP parameter to control the PDF page displayed in Reader ChrisRChamberlain (Programmer)1 Aug 04 16:46Rick
In an earlier thread in Forum184, (thread no longer exists as was off-topic to the forum), Sammybobo stated he was unhappy with the Adobe Acrobat ActiveX Control for reasons various.
In this current thread Sammybobo is looking for a means of interfacing with the Adobe Reader as opposed to the Adobe Acrobat ActiveX Control.
To answer your question as to how to determine the starting page with the Adobe Acrobat ActiveX Control, tryCODEWITH THISFORM.OleControl1
.Src = [C:\temp\test.pdf]
.SetCurrentPage(9)
ENDWwhere the value of the numerical parameter passed to the method .SetCurrentPage() equates to the page no in the .pdf FAQ184-2483 - answering getting answered.Chris
PDFcommandertm.com
PDFcommandertm.co.uk
RE: VFP parameter to control the PDF page displayed in Reader ChrisRChamberlain (Programmer)1 Aug 04 16:53
Apologies - an alternative to the code posted would beCODEWITH THISFORM.OleControl1
.LoadFile([C:\temp\test.pdf])
.SetCurrentPage(9)
ENDW FAQ184-2483 - answering getting answered.Chris
PDFcommandertm.com
PDFcommandertm.co.uk
RE: VFP parameter to control the PDF page displayed in Reader RickSchummer (Programmer)1 Aug 04 20:46Thanks for the clarification Chris. I did not understand the full history.
To be clear on my end, I am not recommending the Acrobat control that you can include on a form. I have found it fairly unstable. It was designed to work with IE only, and despite some documentation I read demostrating using it with VB6, I don't trust it enough to rely on it. I got it to work, but I also get it to C5 regularly.
I recommend working with the Acrobat Typelib, which I access via the Class Browser. This is done via a CREATEOBJECT(). The tricky part is understanding the interface.
_RAS
www.whitelightcomputing.com
VFP MVP RE: VFP parameter to control the PDF page displayed in Reader ChrisRChamberlain (Programmer)2 Aug 04 03:44Rick
I share your concerns about the Adobe Acrobat ActiveX Control and don't use it for the same reasons.
I've found the Adobe Reader to be the most reliable, so where a VFP app is going to need it, the app checks to see if the Adobe Reader is running and, if not, launches it minimized to the taskbar at the same time that the VFP app is instantiated.
On closing the application, the app checks to see if the Adobe Reader is running and offers to close it if it is.
The limit of only 20 pdfs being available in the Adobe Reader can be a problem but it then puts the onus on the user as which open pdfs to close.
Bringing a pdf to be the active window in the Adobe Reader is simply a question of launching it again from within the VFP app.
It sounds as though Sammybobo may have one unacceptable option as an answer to his problem - the Adobe Acrobat ActiveX Control, unless there is an answer using the Acrobat Typelib? FAQ184-2483 - answering getting answered.Chris
PDFcommandertm.com
PDFcommandertm.co.uk
RE: VFP parameter to control the PDF page displayed in Reader RickSchummer (Programmer)2 Aug 04 09:29There is an answer with respect to the TypeLib, and Mike G has already posted a pointer to the Document Viewer. I have not tested it though on a Reader only machine, but I think it might work. _RAS
www.whitelightcomputing.com
VFP MVP RE: VFP parameter to control the PDF page displayed in Reader ChrisRChamberlain (Programmer)2 Aug 04 09:50Rick
I wasn't discounting Mike Gagnon's suggestion from a technical point of view, but purely from a cost point of view.
Installing Adobe Acrobat, even with a volume software licencing program, on each user machine involved is likely to be a costly exercise to achieve the ability to predetermine the starting page in a pdf.
I have assumed, always dangerous , such costs would be prohibitive. FAQ184-2483 - answering getting answered.Chris
PDFcommandertm.com
PDFcommandertm.co.uk
RE: VFP parameter to control the PDF page displayed in Reader Sammybobo (Programmer)(OP)5 Aug 04 14:44Thanks so much, guru guys! I appreciate everyone's very valuable contributions.
The prohibitive cost aspect would make the Document Viewer approach impracticable. If I decide to go with the ActiveX approach, is the Adobe Acrobat ActiveX control in 6 better or more stable than in 5? I'll appreciate if you can share with me any known issues on that particular control.
Again, thanks to you all wonderful guys for coming to the rescue.
Sammybobo RE: VFP parameter to control the PDF page displayed in Reader RickSchummer (Programmer)5 Aug 04 15:08MegaFox is a book from Hentzenwerke. One of the chapters I wrote for this book is the chapter on PDFs. This chapter is one of the samples in the book that you can download from Hentzenwerke. So you can read all about it before plunking down your $50.
As to solving your problem, in the chapter is an example (PdfDisplay5a.scx) which uses the TypeLib instead of the OCX. This form has a reference to the display and a reference to the AVDoc object (another object in the Acrobat control). This object has access to the Page View object via the GetAVPageView() method. Now with this reference I can get to the GetPageNum() method. I added a text box and some code to the form in the textbox Refresh()
CODEIF ISNULL(thisform.oAVPage)
ELSE
this.Value = thisform.oAVPage.GetPageNum()
ENDIF
RETURN
This displays the page number (Acrobat pages are zero relative).
I have tested this under the full version of Acrobat v5. I do not have 6 loaded yet (it is on the shelf waiting for me to reformat this harddrive). You will also have to test it with the Reader in case this is the deployment situation, but I think I tested this a long time ago and it worked, but I could be remembering one of many other tests I have done with PDF technology.
Hope this helps.
_RAS
www.whitelightcomputing.com
VFP MVP RE: VFP parameter to control the PDF page displayed in Reader ChrisRChamberlain (Programmer)6 Aug 04 03:42SammyboboQuote (Sammybobo):...is the Adobe Acrobat ActiveX control in 6 better or more stable than in 5?Suggest you start a new thread in this forum as your question is off-topic to this thread.
The thread title may attract the attention of those with sufficient experience to comment. FAQ184-2483 - answering getting answered.Chris
PDFcommandertm.com
PDFcommandertm.co.uk
RE: VFP parameter to control the PDF page displayed in Reader Sammybobo (Programmer)(OP)12 Aug 04 16:45Hi Rick:
Thanks for pointing me to the PDFDisplay example. I actually have the book but never really noticed the type library interface. I found it more stable than the ActiveX control itself.
Good news! I spoke with Adobe and asked if the interface needs to be licensed . They told me that it is free; just like the OCX. I found that the type library is available also in the installed directory of the Reader, and not just only in the full blown Acrobat.
Sammybobo RE: VFP parameter to control the PDF page displayed in Reader ChrisRChamberlain (Programmer)20 Aug 04 10:56Sammybobo
Just reread your last post and I'm confused.Quote (Sammybobo):I found that the type library is available also in the installed directory of the ReaderThe only .tlb to be found in the n:\Program Files\Adobe\Acrobat 6.0\Reader\ActiveX folder is pdf.tlb.
If you examine the file in the VFP Object Browser you will see that this is the ActiveX control.
If you examine the file n:\Program Files\Adobe\Acrobat 5.0\Acrobat\acrobat.tlb in the VFP Object Browser you will see that this is the one you need.Quote (Sammybobo):Good news! I spoke with Adobe and asked if the interface needs to be licensed . They told me that it is free; just like the OCX.Perhaps you could clarify the situation? FAQ184-2483 - answering getting answered.Chris
PDFcommandertm.com
PDFcommandertm.co.uk
RE: VFP parameter to control the PDF page displayed in Reader Sammybobo (Programmer)(OP)20 Aug 04 12:47Hi Chris:
Sorry for the confusion. I posted another reply after the one to which you referred. It was around the time this web site was updated and it seems that it failed to make the post. Sorry about that.
You are right, I tested the pdf.tbl in the Reader directory and VFP threw an error at me to the effect that the full blown Adobe Acrobat is needed. The person I spoke with at Adobe must have misunderstood or misinformed me. Yeah, Adobe Acrobat is needed to use the type library interface method. Thanks.
Sammybobo googletag.cmd.push(function() googletag.display('div-gpt-ad-1406030581151-2'); ); Red Flag This PostPlease let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.
CancelRed Flag SubmittedThank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.