Solved

Open a PDF document and goto specific page

Posted on 2004-04-09
10
3,069 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 32

Expert Comment

by:jadedata
ID: 10795407
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
ID: 10829145
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
ID: 10829182
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Author Comment

by:BillPowell
ID: 10844606
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
ID: 10844695
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
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10844775
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
ID: 10844786
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
ID: 10845469
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
ID: 10845794
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
ID: 10845813
<<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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

690 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