473,395 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 10451
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: tbrothers | last post by:
I'm new here so if I posted this incorrectly please go easy. I recently moved my website from a Unix hosting service to a Windows 2003 IIS hosting service. The site was converted from php/mysql...
0
by: SampathTangudu | last post by:
Hi, We are trying to use the Hash Tables for passing information from one aspx page to another aspx page. We are using the below code. IsolatedStorageFile isoStore =...
8
by: Michael | last post by:
I am running a web server (IIS) on Windows 2003 SP 1. My ASP.NET C# applications run fine. However, my application is a combination of Classic ASP and C#. For some reason when you attempt to...
6
by: chanmm | last post by:
Dear all, I have run the same web application in my Windows XP Pro without any problem but once I deploy it in Windows 2003 Server the message below appear: The system cannot find the file...
4
by: norm4h8 | last post by:
Hi everyone! I have a problem with trying to open a file in C. The following line in my code is suppoed to open a specified file if it exists and create a new one with this name if one doesn't...
9
by: Andrew Poulos | last post by:
I have some js that looks like this: fOpenPDFInNewWindow = function(url,page) { var page = page || 1; newPDF = window.open(url+"#pagemode=bookmarks&page="+page,...
4
lwwhite
by: lwwhite | last post by:
I'm working with VB in an Access 2003 database. I have a form, called "EditWindowsFields," that contains a field called "sourcedoc." I am trying to use the Shell function to open the XML file that is...
0
by: teo | last post by:
Hallo, by a Label on a .aspx page (and the <a href="..."tag behind it) I'm able to open an .html page with : a Frame on the left and on the right the page #1 (among all the ones...
0
by: teo | last post by:
Hallo, I need to open a page with frames; I need to open it NOT with the usual first page in its centre, but with a different page in the centre. Detailed explanation:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.