Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Winforms - Open external pdf file

Tags:

pdf

winforms

I've Googled and searched stackoverflow for this but I've not found an answer that is suitable.

All I want to do is place a button a form, the code behind this button will contain a reference to a location on a harddrive where a pdf file is stored. All I want to do is have it so that when the user clicks the button the pdf file opens in the machines selected pdf reader (this is an internal application so the 2-3 machines that access it will always have adobe acrobat on them).

I've no idea which (if any) of the built in .NET classes can do this.

EDIT: There will be 100's of pdfs all added throughout time, I will have a path reference to one pdf per order in my system which points to a file storage server where the PDF lies. The PDF is not locally hosted.

How can this be done in the simplest sense?

like image 226
BenM Avatar asked Oct 18 '13 15:10

BenM


People also ask

How do I open a PDF externally?

To use the extension, right-click on a PDF link and select the "Open in PDF viewer" item. The extension downloads the PDF file in your default downloads directory and then executes the external command to open the downloaded file with the default PDF viewer (e.g. Adobe Acrobat Reader or FoxIt PDF reader).

Can windows open PDF files?

To view PDF files on your Windows PC, you first need to download a PDF reader. Luckily, many PDF readers, like Adobe Acrobat, have free versions, so you don't have to pay to read PDFs on your computer. Simply download the reader from the internet and follow the prompts to install it on your computer.


1 Answers

You can simply use this code

System.Diagnostics.Process.Start(@"c:\myPdf.pdf");

It will open the file you provide with its associated default program

like image 197
user1567896 Avatar answered Sep 29 '22 08:09

user1567896