[C# Helper]
Index Books FAQ Contact About Rod
[Beginning Database Design Solutions, Second Edition]

[Beginning Software Engineering, Second Edition]

[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

Title: Open a PDF file in C#

[Open a PDF file in C#]

At design time I added a WebBrowser control to the form. When the program starts it uses the following code to open a PDF file in a WebBrowser control.

// Display the PDF file. private void Form1_Load(object sender, EventArgs e) { string filename = Application.StartupPath; filename = Path.GetFullPath( Path.Combine(filename, ".\\Test.pdf")); wbrPdf.Navigate(filename); }

Also at design time I added the file Test.pdf to the project and set its "Copy to Output Directory" property to "Copy if newer" so the file will be in the executable program's directory.

This code gets the program's startup directory and appends the file name Test.pdf. It then makes the wbrPdf WebBrowser control navigate to that file.

Download the example to experiment with it and to see additional details.

© 2009-2023 Rocky Mountain Computer Consulting, Inc. All rights reserved.