简体   繁体   中英

C#, winforms, webbrowser control: get current pdf page number and open to page

I have a two part question about working with pdf files in a webbrowser control. I have a C# winforms project that opens a pdf file (but it actually opens adobe inside the browser). I want to add functionality to add a bookmark so: 1. How can I get the current page the user is on and 2. how can I open the pdf to that page. Right now I use navigate like this:

wb.Navigate(new Uri(url));

where:

wb is a WebBrowser control url is a string to the pdf file

I also open pdf's in adobe outside of the WebBrowser like this:

Process p = new Process();
p.StartInfo.FileName = // some string 
p.StartInfo.FileName = "acroRd32";
p.StartInfo.Arguments = "/A \"page=n\" " + FileFullyQualifiedPath;
p.Start();

where n is the page number to open.

Any help is greatly appreciated!

of course I just found the answer to one part of my question...

if anyone is interested if you add @"#page=n" where n is the page number to the end of your url you will open the desired page.

I also found a way to navigate to different pages in the same pdf file and answered my own question here:

Stack overflow thread

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM