Viewing PDF in Windows forms using C# [closed]

2020-01-25 06:59发布

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?

5条回答
我命由我不由天
2楼-- · 2020-01-25 07:27

Web Browser control might work. http://ryanfarley.com/blog/archive/2004/12/23/1330.aspx

Also a bunch of pdf open source c# projects here http://csharp-source.net/open-source/pdf-libraries

查看更多
祖国的老花朵
3楼-- · 2020-01-25 07:32

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");
查看更多
虎瘦雄心在
4楼-- · 2020-01-25 07:32

http://www.youtube.com/watch?v=a59LvC6BOuk

Use the above link

private void btnopen_Click(object sender, EventArgs e){
    OpenFileDialog openFileDialog1 = new OpenFileDialog();
    if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK){
        axAcroPDF1.src = openFileDialog1.FileName;
    }
}
查看更多
混吃等死
5楼-- · 2020-01-25 07:35

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

查看更多
登录 后发表回答