I was trying to use Process.Start to launch Adobe Reader and open a PDF file from a C# Windows Form applicatoin. I want the file to be opened at a specific page, so I tried:
Process.Start("C:\\ABC.pdf", "/a Page=3");
This launches Adobe Reader and brings up the correct file, but it goes to Page 1, not Page 3.
I know that from a command line the following works:
AcroRd32.exe /a Page=3 C:\ABC.pdf
But this does not:
AcroRd32.exe C:\ABC.pdf /a Page=3
I am assuming that Process.Start is putting the arguments at the end of the command line and Reader is ignoring them.
Can anyone suggest a way to make this work? I am not married to using Process.Start, so any suggestions would be greatly appreciated.
Thanks,
DP
2 7070
Try something like this: -
string acro = @"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe";
-
System.Diagnostics.ProcessStartInfo st = new System.Diagnostics.ProcessStartInfo(acro, "/a page=2 c:\\dev\\a.pdf");
-
System.Diagnostics.Process p = new System.Diagnostics.Process();
-
p.StartInfo = st;
-
p.Start();
-
Note that you will have to replace the location of the AcroRd32.exe with the path to the version currently installed on your machine.
This worked for me.
I was trying to use Process.Start to launch Adobe Reader and open a PDF file from a C# Windows Form applicatoin. I want the file to be opened at a specific page, so I tried:
Process.Start("C:\\ABC.pdf", "/a Page=3");
This launches Adobe Reader and brings up the correct file, but it goes to Page 1, not Page 3.
I know that from a command line the following works:
AcroRd32.exe /a Page=3 C:\ABC.pdf
But this does not:
AcroRd32.exe C:\ABC.pdf /a Page=3
I am assuming that Process.Start is putting the arguments at the end of the command line and Reader is ignoring them.
Can anyone suggest a way to make this work? I am not married to using Process.Start, so any suggestions would be greatly appreciated.
Thanks,
DP
Thanks for the suggestion, the problem is that the app (which will be run on many different machines) has no way of knowing what version of Reader (or some other program for reading PDFs) the machine has installed, or where it is installed.
Thanks,
DP
Try something like this: -
string acro = @"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe";
-
System.Diagnostics.ProcessStartInfo st = new System.Diagnostics.ProcessStartInfo(acro, "/a page=2 c:\\dev\\a.pdf");
-
System.Diagnostics.Process p = new System.Diagnostics.Process();
-
p.StartInfo = st;
-
p.Start();
-
Note that you will have to replace the location of the AcroRd32.exe with the path to the version currently installed on your machine.
This worked for me.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: PM |
last post by:
Has anyone found a way to open a file exclusively where it
will fail if the file is already open, i have tried the
following
_FileStream = new FileStream(@"C:\Data.txt",
FileMode.Open,...
|
by: Alfons |
last post by:
Hello,
I have build a program that can do file transferring between a Windows
XP computer and a DOS computer via a serial port. The Windows program
I have build in C++ with Visual Studio 6.0....
|
by: sunil |
last post by:
Hi all,
I have a web application in which I have to open a "chm" file that
exists on the local file system. I am able to open other files such as
PDF, DOC files by writing the Response's output...
|
by: emailus |
last post by:
I am webmaster for the domain <www.alpha1.org.au>.
Not being an expert in html, I take advantage of my domain
Registrant's web building tool, 'Instant Website'. This tool is
provided as part of...
|
by: compman9902 |
last post by:
Hello, and thank toy for reading this post.
Thus far, this website has helped me a lot,
(I have finally finished my encryptor: "site removed by moderator", go to the downloads link) and I will...
| |
by: Jeremy Noring |
last post by:
Hi,
I have an application that loads various settings from the
app.exe.config file. This has worked very well on w2k, XP, and
Vista.
However, recently I've been troubleshooting an issue on...
|
by: kimiraikkonen |
last post by:
Hi,
I have an app which has a listbox and when i double click an
associated fileS, i want their paths to be added into listbox in my
application.
This code works good when i try to open a...
|
by: bushwacker |
last post by:
Hello all,
I'm a chemical engineering student. our teacher has given us a project to do some calculations based on some equations. those equations include constants, which are to be read from a...
|
by: Alexnb |
last post by:
Gerhard Häring wrote:
No, it didn't work, but it gave me some interesting feedback when I ran it
in the shell. Heres what it told me:
Traceback (most recent call last):
File...
|
by: navanova |
last post by:
Greetings,
I have a problem of opening ms word and excel files on my computer. The files are there for a long time. I use to open and modify them. Suddenly, when i try to open the word files, a...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |