472,780 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 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 10338
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.