• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3181
  • Last Modified:

Open a PDF document and goto specific page

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
BillPowell
Asked:
BillPowell
  • 5
  • 4
1 Solution
 
jadedataMS Access Systems CreatorCommented:
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
 
Karl Heinz KremerCommented:
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
 
Karl Heinz KremerCommented:
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
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
BillPowellAuthor Commented:
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
 
BillPowellAuthor Commented:
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
 
Karl Heinz KremerCommented:
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
 
Karl Heinz KremerCommented:
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
 
BillPowellAuthor Commented:
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
 
Karl Heinz KremerCommented:
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
 
BillPowellAuthor Commented:
<<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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now