-
Opening a PDF Page
I need to use VB to open a PDF document and jump to a particular page within it.
I can view a PDF document by opening the Reader using ShellExecute, or by using the ActiveX control pdf.ocx but have no idea about specifying a page to jump to.
Can this be done, any ideas?
-
eeewwwww...don't do it that way....if you have Acrobat and not the reader then just click on Project/References then attach the Adobe Acrobat Type Library and then from adobe.com get their SDK. I have been working with it for almost 6 months now and there is a lot you can do but if you really wanna start working with PDF's then you will need to start using Visual C++. Also, the Java interface with Acrobat 5 will let you do a lot of things. The SDK also covers that.
Have fun and good luck!
-
Cheers, but it must be VB and I can only use Reader.
I have looked at the SDK and it's pretty much C++ orientated - I'm looking for something simple - the only operation I need to carry out is to open a document ona certain page.
-
hehe....look in the IAC section that is the VB and java with VB section. Seriously..to open a document and go to a certin page is easy.
-
Aha, the old setCurrentPage function of the ActiveX control seems to do the trick!
Not sure I like having the document embedded in a form but it's a start.
-
uuuhhhhh......thats not what I wanted you to get into....you can control the real acrobat from a VB front-end....I don't really wanna spell it out for you because you say that you got the SDK and all the information is in there BUT.....do something like this:
Start a new project then click on Project/References then check the Adobe Acrobat 5.0 Type library
Then hit F2 to bring up your object browser then select Acrobat as the object to view then look at the CAcroAVPageView.
Its easy to use and here is a little code to get you started:
'----------------------------------------
Private Sub Form_Load()
Dim AcroApp As CAcroApp
Dim AVDoc As CAcroAVDoc
Dim PDDoc As CAcroPDDoc
Dim AVPage As CAcroAVPageView
Dim PDPage As CAcroPDPage
Dim pNum As Long
Dim IsSuccess As Boolean
Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")
Set AVDoc = AcroApp.GetActiveDoc
Set PDDoc = AVDoc.GetPDDoc
Set AVPage = AVDoc.GetAVPageView
Set PDPage = PDDoc.AcquirePage(AVPage.GetPageNum)
AcroApp.Show 'lets make sure it doesn't hide acrobat on us
If AVDoc.IsValid Then
AVPage.GoTo 2 'put whatever page you wanna goto there but keep in mind
' that page 1 is 0
End If
'Un-comment these lines to close acrobat and clear everything out
'Close the PDF
'AVDoc.Close True
'AcroApp.Exit
'Cleanup
'Set PDDoc = Nothing
'Set AVDoc = Nothing
'Set AcroApp = Nothing
End
End Sub
'----------------------------------------
Open a document with atleast 3 pages then run this code.
Now look at your open document...it should be on page three
-
I am trying to work with PDF files, and I have the SDK.
In my project I have set a reference to the Adobe Acrobat 5.0 Type Library,
but at the line:
Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")
I get an ActiveX can't create object error. Now I know what this error means etc. But I have set the reference, so why is this happening?