Solved

Open a PDF document and goto specific page

Posted on 2004-04-09
10
2,948 Views
Last Modified: 2012-06-22
I have a manual that is online as a pdf document.  From an Access command button, I would like to open that pdf and goto a specific page.  The specific page would depend on a textbox value that would allow the code to reference a table to see which page to navigate too.  See table structure below:

tblLUBpage

Zone    Page
RS-1      29
RS-2      31

I have opened pdf's from Access before, but never done any navigating.  How should I start with this?
0
Comment
Question by:BillPowell
  • 5
  • 4
10 Comments
 
LVL 32

Expert Comment

by:jadedata
Comment Utility
Greetings BillPowell!

  Bill:   did they pass a law in your state that requires the questions to get so difficult ??
  This is looking like a job for the Adobe API (if such a thing exists) to access the function you're looking for.
  I'll see if I can find it out the for you dude!

regards
jack
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
Bill, did I ever give you the link to the SDK? If so, lookup the documentation for the JSObject (you need VB6 for this). With this VB->JavaScript bridge you can then use the JavaScript objects and jump to any page you want. If you don't have the API yet, go to this page and download the _VERSION 5_ (this was the last one that was distributed for free): http://partners.adobe.com/asn/acrobat/download.jsp#fullinstall - you need to create a free web account.
You can also pass a command line argument to Acrobat to have to open a PDF document on a specific page. You can find more about all the "PDF Open Parameters" in this document: http://partners.adobe.com/asn/acrobat/sdk/public/docs/PDFOpenParams.pdf
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
One more method (which does not require VB6, so you should be OK with VBA). You can use the OLE automation interface and use the AcroExch.AVPageView object's Goto method. It takes a page number. Just keep in mind that Acrobat starts to count pages with page 0 (that's the first page in the document).

The JavaScript code for changing the page (in this example to page 5) is:
this.numPage = 4;
This is a method in the Doc object.

0
 
LVL 11

Author Comment

by:BillPowell
Comment Utility
Sorry for the delay.  Took me a while to look into that, but Ive downloaded the SDK and managed to use the following code to open a PDF by passing the procedure a URL.  Now my problem is how to implement the page navigation.  I know your not fluent in VBA but perhaps youll have some idea where I need to go from here.  Also, Jack may still be listening in on this one.  He knows VBA quite well:

    Function PdfCheck(ByVal URL As String)
    On Error Resume Next
        Dim AcroApp As Acrobat.CAcroApp
        Dim PDDoc As Acrobat.CAcroPDDoc
        Set AcroApp = CreateObject("AcroExch.App")
        Set PDDoc = CreateObject("AcroExch.PDDoc")
       
        AcroApp.Show
        PDDoc.Open (URL)
        PDDoc.OpenAVDoc (URL)
       
    End Function
0
 
LVL 11

Author Comment

by:BillPowell
Comment Utility
Also, out of curiosity, I noticed that when opening a pdf this way it opens lightening fast.  No font loading, no waiting while viewing the Adobe logo.  Why is that?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
Please keep in mind that I don't program in VB (not at all!), so this may be just stupid, but I'll try anyway :-)


Dim AVDoc As Acrobat.CAcroAVDoc
Dim AVPageView As Acrobat.CAcroAVPageView
Dim AcroApp As Acrobat.CAcroApp
 
Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")

AVDoc.Open(URL, "")

Set AVPageView = AVDoc.GetAVPageView
AVPageView.Goto(4)

For this to work, you need an AVDoc instead of a PDDoc (an AVDoc is the document when it's displayed in Acrobat, a PDDoc is opened "behind the scenes" and is not displayed).



0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
It only opens lighning fast if you do this twice (or with Acrobat already running). When you exit your program, Acrobat is still running in the background, so it does not have to be loaded again.
0
 
LVL 11

Author Comment

by:BillPowell
Comment Utility
Ok, now were getting somewhere.  The code below now works perfect for any pdf that is on our network.  It wont work with pdf documents on the web though.  When I try to use this code and pass a web url then I first get an error with Acrobat:  There was an error opening this document. The filename, directory name, or volume label syntax is incorrect.  Then I get a VB runtime error.  This is not a show stopper for me.  Im happy just to figure out how to do this with any pdf.  I just though it might be something simple that Im doing wrong.  


Private Function PDF_Navigate(ByVal URL As String, intPage As Integer)

Dim AVDoc As Acrobat.CAcroAVDoc
Dim AVPageView As Acrobat.CAcroAVPageView
Dim AcroApp As Acrobat.CAcroApp
 
Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")

AcroApp.Show
AVDoc.Open URL, "Title"
Set AVPageView = AVDoc.GetAVPageView
AVPageView.Goto intPage

End Function

0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 500 total points
Comment Utility
Acrobat does not open files on a web server. At least not by "just opening" them. You can download a PDF file if you load a FDF file that references a PDF file, but then you don't have access to the PDDoc/AVDoc/AVPageView information.
You can enumerate all open PDF files and find out which AVDoc corresponds with your just opened file and goto your specific page, but it's more effort than for a file that you open the way you just described.

Hey, my VB code was pretty close, maybe I have a future as VB programmer :-)
0
 
LVL 11

Author Comment

by:BillPowell
Comment Utility
<<Hey, my VB code was pretty close, maybe I have a future as VB programmer :-)>> I think you just might :)

Perhaps I will delve deeper into the web server issue at a later date.  In the meantime, this will do nicely.

Thanks so much.

Bill
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 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

9 Experts available now in Live!

Get 1:1 Help Now