?
Solved

Open a PDF document and goto specific page

Posted on 2004-04-09
10
Medium Priority
?
3,100 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…
Suggested Courses

770 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