Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a pdf file at a specified page in C#

Status
Not open for further replies.

polocar

Programmer
Sep 20, 2004
89
IT
Hello,
I'm writing a program in C#.
In the interface you have 2 textboxes in which you can specify the pdf file name (with its position in the hard disk) and the page of that file you want to go directly.
I would like that, when the user clicks on an appropriate "Open" button, the pdf file would open exactly at that page.
I have found in other threads of the forum that the correct way to open a pdf file in a C# program is to use

using System.Diagnostics;

namespace, and then the

Process.Start("namefile.pdf");

statement.
In this way the pdf document opens at page 1.
Is there a way to open it at the page specified in the textbox?

Thank you very much
 
As far as I know there are no command line options available to do what you are asking at pdf open. The only way that I see to do it is to have a full install of Acrobat (not just the reader) - and include Acrobat.tlb as a project reference.

This may or may not be an option for what you want to do. This developer faq may be of some use (where I got the above information). If you want to be a hack about it... you could always do some send keys or something to the reader to get to the page you want... lol

Good luck!

 
Hi rdgerken,
thank you for your suggestion.
I think your method is surely useful if you want to have the complete control of the pdf file.
For the moment I only try to find a simple way to open a pdf file at a specified page.
Just 10 minutes ago I have found (thanks to another user that indicated me the link) an interesting article that gave me an idea on how to do:

the article is this one:

It seems to me that these statements could function:
After having introduced the namespace

using System.Diagnostics;

you can define a Process object and initialize its StartInfo property in this way:

Code:
Process myProcess = new Process();
myProcess.StartInfo.FileName = "Acrobat.exe";
myProcess.StartInfo.Arguments = "/A \"page=2\" C:\\example.pdf";
myProcess.Start();

The pdf file should open at page 2.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top