471,325 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

Open a pdf file at a specified page in C#

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

Feb 20 '06 #1
3 10138
Hi,

You can use the page=<num> parameter. Check this document:

http://partners.adobe.com/public/dev...Parameters.pdf

Regards - Octavio
"polocar" <po*****@tin.it> escribió en el mensaje
news:11**********************@f14g2000cwb.googlegr oups.com...
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

Feb 20 '06 #2
Hi Octavio,
thank you for your response.
The document you suggested me lists the parameters you can use when you
open a pdf file from a command line statement (and one of these
parameters is the page number).
A typical command line statement example is:

Acrobat.exe /A "zoom=1000=OpenActions" "C:\example.pdf"

I have tried to adapt this concept to the C# Process.Start method.

These are my attempts:

Process.Start("C:\\example.pdf");
// It functions but opens the pdf file at page 1

Process.Start("C:\\example.pdf", "page=2");
// It functions but opens the pdf file at page 1

Process.Start("Acrobat.exe /A \"page=2\"", "C:\\example.pdf");
// It doesn't function (error: "impossible to find the specified
file",
// even if I created an "example.pdf" file in C:)

I also have studied the StartInfo property of Process class, but I
think it gives no more possibilities than the Start method used with
arguments.

In which way can I introduce the "page=<num>" parameter in the
Process.Start statement?

Thank you very much

Feb 21 '06 #3
Ok, finally I have found the solution.
After having introduced the namespace

using System.Diagnostics;

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

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

The pdf file will open at page 2.

Feb 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Michael | last post: by
4 posts views Thread by norm4h8 | last post: by
9 posts views Thread by Andrew Poulos | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.