0

I just want to open a pdf file and not to use it. If the user wants to be able to print via a glider. I want to just pressing a button will open the file if Acrobat Reader to view

shlomi
  • 3
  • 1
  • 2
  • Do you want to know how to show an OpenFileDialog to ask the user for a filename, or do you want to know how to launch a filename in Adobe Reader? – Joe White Sep 06 '11 at 23:34
  • 1
    "Print via a glider" is very hard to interpret, you'd normally fly them. I'd guess at the Process class, possibly ProcessStartInfo.Verb = "print". – Hans Passant Sep 06 '11 at 23:42

2 Answers2

3

To open the PDF, try using the following code with the PDF's filename as the command.

string command=@"c:\Users\User\Desktop\hello.pdf";

var process = new System.Diagnostics.Process
            {
                StartInfo =
                    new System.Diagnostics.ProcessStartInfo(command)
            };

process.Start();
Eugenio De Hoyos
  • 1,755
  • 16
  • 22
  • how to launch a filename in Adobe Reader? – shlomi Sep 06 '11 at 23:54
  • This is the correct answer. The ProcessStartInfo method will open your file with whatever default program your machine is registered to use. So if you have Adobe as your default PDF viewer, it'll open the PDF file via Adobe. Make sure to check the file exists before running the process though. – Only Bolivian Here Sep 06 '11 at 23:56
  • @shlomi: If you run the code you will open the file with whatever software is the default. Are you asking how to specify the application you want to open it with? – Only Bolivian Here Sep 06 '11 at 23:57
  • The operating system will launch Adobe Reader automatically based on the file name extension of the command that you give it. In this case, the command string ends with ".pdf", which the operating system will relate to Adobe Reader, assuming that it is installed in the system. – Eugenio De Hoyos Sep 06 '11 at 23:58
2

Visual Basic CODE:

  Dim FilePath As String = "<YourFilePath>" & "<YourFileName>" & ".pdf"
  Dim Process As System.Diagnostics.Process = New System.Diagnostics.Process
  Process.StartInfo.FileName = FilePath
  Process.Start()

Every time the relative pdf file will show on a separate window

Obviously you MUST HAVE Adobe Reader INSTALLED on the CLIENT PC

It works pefectly. Used in Visual Studio 2010.