Opening pdf in .NET

In the application we are working on, we are trying to implement Help. We have a pdf help document, and at the moment it is considered acceptable that when users click the help button, it simply opens the PDF file. The application is a desktop application, and the pdf file must somehow be included in the installation and installed on the local computer.

I need two things:

  • How would I add this pdf file to the application so that it is available on the client machine after installation? I can either put it in the project resources, otherwise I could put this in the application folder installer of the client installation.

  • How do I open this pdf file? I can either open this pdf, just launch the default PDF viewer for the file, or I can use the System.WinForms.WebBrowser Tool to display it. However, if I choose the second option, I'm not sure how to access the file stored in the resources or find it in the installation folder.

If you could provide me the code for this (either in VB.Net or in C # .Net), that would be great.

+3
source share
5 answers

Here's how we did it:

%ApplicationFolder%/Help. , pdf %ApplicationFolder%/Help/Manual.pdf. pdf csproject csproject copy always. , , pdf , Help, .

( pdb, ) .

System.Diagnostics.Process.Start(pdfPath), . pdfPath:

:

public void Help_Click(object sender, System.EventArgs e)
{
    var appDir = Path.GetDirectoryName(Application.StartupPath);
    var helDir = Path.Combine(appDir, "Help");
    var pdfPath = Path.Combine(helDir, "Manual.pdf");

    System.Diagnostics.Process.Start(pdfPath);
}

. F5 ( PDF ),

+3
  • IMHO, pdf , . , .

  • pdf .NET ActiveX WebBrowser. , - Acrobat , . AxAcroPDF, AxAcroPDF.LoadFile. , AxAcroPDFLib. :

    var axAcroPDF = new AxAcroPDFLib.AxAcroPDF();
    axAcroPDF.Dock = System.Windows.Forms.DockStyle.Fill;
    axAcroPDF.Enabled = true;
    axAcroPDF.Name = "axAcroPDF1";
    axAcroPDF.LoadFile(fullFilepath);
    axAcroPDF1.Visible = true;
    

ps Adobe Acrobat .

+2

PDF Visual Studio " " ", ". , , PDF . .NET Process, , :

System.Diagnostics.Process.Start(fullFilePath);
+1
  • pdf , ? , .

, , , ...

  1. pdf ? pdf, PDF , System.WinForms.WebBrowser . , , , , , .

- . IMHO... PDF , , , .

0

I am not a very experienced programmer, but I suggest the "Application Folder" proposed by Thomas, plus if you are worried that the client system may not have a default PDF viewer, you can try implementing "TRichEditPDF 1.01", / " TRichView llPDFLib 1.0 "or" PDFsharp 1.30 ". I don’t know if it is very practical or not, but this is an option.

0
source

Source: https://habr.com/ru/post/1721254/


All Articles