Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP parameter to control the PDF page displayed in Reader

Status
Not open for further replies.

Sammybobo

Programmer
Apr 4, 2003
87
US
Hi:
Is there a way to use parameters from VFP to force Acrobat Reader to display a particular page in a multiple-page document? Say, to display page 10 instead of 1 through a command in VFP. Thanks.

Sammybobo
 
As Acrobat Reader is not an automation server, VFP cannot communicate with in the conventional way.

AFAIK, there are no command line parameters that would achieve what you are seeking, but you could ask the question at Abobe.

The only other and probably totally impractical way would be to modify the code of the postscript file, (assuming you can access it), and make it so that the pdf always started at page n.

But once the pdf had been distilled into a pdf, it would always start at page n. [sad]

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Sammybobo

Apologies
But once the pdf had been distilled into a pdf, it would always start at page n
should be
But once the postscript file had been distilled into a pdf, it would always start at page n

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Sammybobo

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.
 
Look 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
ltc.jpg
 
Chris,

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
VFP MVP
 
Rick

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, try
Code:
[COLOR=blue]WITH THISFORM.OleControl1
[tab].Src = [C:\temp\test.pdf]
[tab].SetCurrentPage(9)
ENDW[/color]
where 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 [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Thanks 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
VFP MVP
 
Rick

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 [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Rick

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 [smile], such costs would be prohibitive.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Thanks 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
 
MegaFox 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()

Code:
IF 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
VFP MVP
 
Sammybobo
Sammybobo said:
...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. [smile]


The thread title may attract the attention of those with sufficient experience to comment.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Hi 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
 
Sammybobo

Just reread your last post and I'm confused.
Sammybobo said:
I found that the type library is available also in the installed directory of the Reader
The 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.
Sammybobo said:
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 [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Hi 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top