Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > Third Party Products

Third Party Products Discussion on third party components for VB.NET

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-03-2009, 2:00 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Jul 2009
Posts: 5
Reputation: 0
Bruce_P is on a distinguished programming path ahead
Default Navigating PDF files in vb.net

Hi all,

I'm trying to add some help functionality to a vb.net app by loading a PDF file and displaying a specific page in the document. This is a PDF that I don't have the original source to so I can't modify it. I can launch the Adobe Reader and have it display a particular page within a PDF without any problems using the following (I'm not hardcoding these values in the app, this is just for demonstration purposes):

Dim adobePath as String = "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe"
Dim params as String = "/A zoom=100&page=3 c:\temp\foo.pdf"
System.Diagnostics.Process.Start(adobePath, params)

Adobe documents how to pass parameters to Acrobat in this document: http://www.adobe.com/devnet/acrobat/...ameters_v9.pdf

What I'm trying to figure out now is how to switch to a different page. If a user is running my app and they view one help page I want to be able to switch to another help page on demand if they ask for help elsewhere.

If I launch the help file as described above, the Adobe Reader launches and shows pages 3 of foo.pdf. If I then scroll to another page of the PDF then try to execute the above code a second time it doesn't revert back to page 3. Since this is just trying to re-launch the application that makes sense - the application is already running...

So I tried creating a form with a WebBrowser object in it and load the pdf this way:

HelpForm.WebBrowser1.Navigate("file:///c:/temp/foo.pdf#zoom=100&page=3")

Once again when initially invoked it displays the PDF file on page 3 as requested. However if I then try to navigate to a different page it again ignores the parameters. I would have hoped that since the URL has changed (say to page=10) that the browser object would recognize the change and display the new page, but no dice.

So the next thing I tried was deleting the web browser object then re-creating it, hoping that it would re-initialize everything. But even that doesn't work. So if I invoke the above Navigate method, manually scroll the PDF to page 10, dispose the form that WebBrowser1 is in, recreate the form, and invoke the above Navigate method a second time then the PDF still shows up on page 10 and not page 3. I've even gone so far as to try to dynamically create the WebBrowser object and dispose of it each time but even that doesn't work.

Any suggestions as to how I might be able to get this to work? It's starting to look like the only way I might be able to do it is to have my app invoke the Acrobat Reader to display the PDF but first terminate any running instances of Acrobat. That's a pretty ugly hack as far as I'm concerned and I'm not even sure how to go about doing it.

Thanks,

-Bruce
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-03-2009, 5:43 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,173
Reputation: 1273
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

You can also add a "Adobe Pdf Reader" control to a form. Choose items for Toolbox and select it in COM list, then add it to form. Use methods LoadFile and setCurrentPage.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-04-2009, 10:54 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Jul 2009
Posts: 5
Reputation: 0
Bruce_P is on a distinguished programming path ahead
Default

Thanks, that was exactly what I was looking for!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-05-2009, 7:13 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jul 2009
Posts: 3
Reputation: 0
u-sef is on a distinguished programming path ahead
Default

thank you very much, I was trying to build a simple bookmark application and I wanted to post a question about how to open PDF file and assign a page number to be opened

but how to use these function, I mean what references and Libraries to add to my project.
e.g.: "Acrobat Access 3.0 type liberary" or what are needed

thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-05-2009, 7:28 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,173
Reputation: 1273
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

Quote:
Originally Posted by u-sef
I mean what references and Libraries to add to my project.
Have a look at post 2 again, all you need is explained there.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-05-2009, 9:11 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Jul 2009
Posts: 5
Reputation: 0
Bruce_P is on a distinguished programming path ahead
Default

Quote:
Originally Posted by u-sef View Post
but how to use these function, I mean what references and Libraries to add to my project.
e.g.: "Acrobat Access 3.0 type liberary" or what are needed
From the Tools menu click on "Choose Toolbox Items". In the window that appears click on the "COM Components" tab and check "Adobe PDF Reader". You'll then see an Adobe PDF Reader icon appear in your Toolbox.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 8:23 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.