Viewing PDF in Windows forms using C# [closed]

主宰稳场 提交于 2019-11-26 08:18:09

问题


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?


回答1:


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");



回答2:


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




回答3:


display PDF file into WinForms

Displaying a pdf file from Winform.

displaying a pdf on a windows form?

How to display PDF or Word's DOC/DOCX inside WinForms window?

Reading/Writing PDF Files in Visual C# Windows Forms




回答4:


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




回答5:


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;
    }
}


来源:https://stackoverflow.com/questions/4504442/viewing-pdf-in-windows-forms-using-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!