Click here to Skip to main content
12,079,489 members (65,714 online)
Rate this:
 
Please Sign up or sign in to vote.
Hiii Guys,
I wanted to launch a File(Pdf format)using C#. Has any one worked on this kind of excercise previously??
pls give some suggestions..

THanks
Sandy
Posted 18-Apr-11 3:59am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Use the types Process and ProcessStartInfo setting ProcessStartInfo.UseShellExecute[^] to true. Then if you set ProcessStartInfo.FileName to the PDF (full path) and the ProcessStartInfo.Verb to something like "open". Create a Process and invoke the Start method with th ProcessStartInfo as a parameter.

If the PDF reader is still associated with the extension PDF this will open the PDF reader with said document.

Best Regars,

-MRB
  Permalink  
Comments
Tarun.K.S 18-Apr-11 9:13am
   
Perfect answer! 5+
Manfred R. Bihy 18-Apr-11 9:31am
   
Thanks Tarun!
Sandy058 19-Apr-11 0:34am
   
thank you Manfred...
5+ :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Use Process.Start :

Process.Start(@"C:\ThisIsA.pdf");
  Permalink  
v2
Comments
Sandy058 19-Apr-11 0:35am
   
thank u Tarun... :)
Tarun.K.S 19-Apr-11 1:58am
   
You're welcome!
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

You didn't specify whether this was for Windows or Web.

For Web, create a URL to the document

For Windows

Process p = new Process();
p.StartInfo.FileName = "myPDF.pdf";
p.Start();


http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[^]
  Permalink  
Comments
Sandy058 19-Apr-11 0:36am
   
Thank you Mark
SAKryukov 19-Apr-11 1:40am
   
Sure, a 5.
--SA
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Try:
Process p = new Process();
ProcessStartInfo s = new ProcessStartInfo(@"F:\Temp\MyPDFFile.pdf");
p.StartInfo = s;
p.Start();
  Permalink  
Comments
Tarun.K.S 18-Apr-11 9:13am
   
Good answer! 5+
Manfred R. Bihy 18-Apr-11 9:34am
   
I'm not quite sure about it, but I thought for that to work one had to set ProcessStartInfo.UseShellExecute to true and also set the Verb property to "open", but alas I might be mistaken once again. :)
Manfred R. Bihy 18-Apr-11 9:35am
   
Doh!
UseShellExecute defaults to true. Y'all ignore my incoherent rambling. :)
OriginalGriff 18-Apr-11 9:40am
   
I saw no ramblings! :TunelessWhistleSmiley:
Nothing to see here, move along!
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 6

http://www.codeproject.com/Articles/37458/PDF-Viewer-Control-Without-Acrobat-Reader-Installe
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 7

it is easy in C#

System.Diagnostics.Process.Start(path);

in managed C++
System::Diagnostics::Process::Start(path);
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

  Permalink  
Comments
Mark Nischalke 18-Apr-11 14:41pm
   
Why would this be helpful to the OP? The question was how to open, not how to create a PDF. This link is also related to ASP.NET where the user need a Windows solution.
Nischal Bhatt 18-Apr-11 15:50pm
   
Apologies, it was not clear to me in the beginning whether it's a windows or asp.net question, My Bad....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160212.1 | Last Updated 27 Nov 2015
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100