Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewing PDF in Windows forms using C# [closed]

Is there any way to view PDF files in a Winforms tool? I've seen solutions such as converting the pdf file into images and showing them in an picture box. However, I am asking whether i can view the file as PDF. Is there any tool from adobe or from Microsoft that supports this?

like image 880
Majd Avatar asked Dec 21 '10 22:12

Majd


People also ask

How do I open a PDF in Visual Studio?

If you've got a PDF file in a project you can right-click in the solution explorer and choose "Open with..". Now you can choose which editor you want to use. If Acrobat isn't already listed you can add it and after that click the button "Set as default".


2 Answers

you can use System.Diagnostics.Process.Start as well as WIN32 ShellExecute function by means of interop, for opening PDF files using the default viewer:

System.Diagnostics.Process.Start("SOMEAPP.EXE","Path/SomeFile.Ext");  [System.Runtime.InteropServices.DllImport("shell32. dll")] private static extern long ShellExecute(Int32 hWnd, string lpOperation,                                      string lpFile, string lpParameters,                                          string lpDirectory, long nShowCmd); 

Another approach is to place a WebBrowser Control into your Form and then use the Navigate method for opening the PDF file:

ThewebBrowserControl.Navigate(@"c:\the_file.pdf"); 
like image 65
ArBR Avatar answered Sep 24 '22 18:09

ArBR


i think the easiest way is to use the Adobe PDF reader COM Component

  1. right click on your toolbox & select "Choose Items"
  2. Select the "COM Components" tab
  3. Select "Adobe PDF Reader" then click ok
  4. Drag & Drop the control on your form & modify the "src" Property to the PDF files you want to read

i hope this helps

like image 27
Saif al Harthi Avatar answered Sep 22 '22 18:09

Saif al Harthi