How to Add PDF Viewer in Winforms C# | Show PDF File in Form

Sdílet
Vložit
  • čas přidán 27. 03. 2023
  • Find the Visual Studio project and Codes here:
    csharp.agrimetsoft.com/exerci...
    How to Add #PDF Viewer in #Winforms #csharp | Show #PDF_File in Form
    ===
    In this video, we're going to show you how to add a PDF viewer to your Winforms C# project. This will allow you to show PDF files in your form windows.
    PDFs are a common sight on the web, and it's important to be able to view them in your forms. With this video, you'll be able to add a PDF viewer to your Winforms C# project, and show PDF files in your form windows!
    =============
    ّForget this video:
    =============
    To add a PDF viewer in Winforms C# and show a PDF file in a form by using adobe acrobat, you can follow these steps:
    Add a reference to the Adobe Acrobat Reader ActiveX control to your project:
    a. Right-click on your project in the Solution Explorer and select "Add Reference".
    b. In the "COM" tab, locate and select "Adobe PDF Reader" or "Adobe Acrobat" from the list of available references.
    c. Click "OK" to add the reference to your project.
    Drag and drop the "Adobe PDF Reader" control from the toolbox onto your Winforms form.
    Set the properties of the control:
    a. Set the "AllowDrop" property to "true" if you want to be able to drag and drop PDF files onto the control.
    b. Set the "src" property to the path of the PDF file you want to display.
    Add event handlers for the "OnError" and "OnReadyStateChange" events of the control:
    a. In the "Properties" window of the control, click on the "Events" button (lightning bolt icon) to view the list of available events.
    b. Double-click on the "OnError" and "OnReadyStateChange" events to create event handlers for them.
    In the event handler for "OnReadyStateChange", set the "Zoom" property of the control to "FitWidth" to display the PDF file at the width of the control:
    a. In the code editor, locate the event handler for "OnReadyStateChange".
    b. Set the "Zoom" property of the control to "FitWidth":
    axAcroPDF1.setZoom("FitWidth");
    Build and run your project to display the PDF file in the Winforms form.
    Here's a sample code snippet to show a PDF file named "example.pdf" in the "axAcroPDF1" control:
    typescript
    Copy code
    private void axAcroPDF1_OnError(object sender, EventArgs e)
    {
    MessageBox.Show("An error occurred while loading the PDF file.");
    }
    private void axAcroPDF1_OnReadyStateChange(object sender, EventArgs e)
    {
    axAcroPDF1.setZoom("FitWidth");
    axAcroPDF1.Refresh();
    }
    private void Form1_Load(object sender, EventArgs e)
    {
    axAcroPDF1.src = "example.pdf";
    }
    Note that you may need to adjust the size of the control to fit your form and set additional properties as needed.
    Tags:
    how to add pdf viewer in winforms c#,pdf reader in c#,c# pdf reader,c# read pdf file,pdf in c#,pdf viewer in winforms c#,c# pdf,pdf viewr control in winforms,c# pdf viewr control,c# pdf viewer,c# show pdf in form,c# pdf file,how to read pdf file in c# windows application,c# pdf generator,show pdf file in windows form c#,show pdf c#,display pdf file in winforms,pdf control in winforms,c# show pdf file in form,winforms show pdf file

Komentáře • 12

  • @dineshsthanki
    @dineshsthanki Před 9 měsíci

    Thank. I learnt not only how to add a pdfViewer to my forms but also, how to add dll functions to the ToolBox. Great video

    • @CExercises
      @CExercises  Před 8 měsíci

      I'm glad it was useful! Thank you for your comment!

  • @kiankolsoumi9692
    @kiankolsoumi9692 Před rokem

    Thanks!

  • @nasrinsalehnia3330
    @nasrinsalehnia3330 Před rokem

    Nice! 😊😊😊

  • @PCh-123
    @PCh-123 Před 3 měsíci

    Will this let you select/highlight the text with the cursor? Or is the pdf just plain image?

  • @khalidaladras3065
    @khalidaladras3065 Před 7 měsíci

    May God bless you. With your permission, can you send me the items or upload them to the channel for everyone’s benefit? Greetings to you.

  • @sergiofonsecabalandran6818
    @sergiofonsecabalandran6818 Před 8 měsíci

    I'm sorry, do you have some information to pay, i would like that red message doesn't appears in my reports, thanks in advanced!

    • @CExercises
      @CExercises  Před 8 měsíci

      Hi, I didn't pay but this is the link of website: www.e-iceblue.com/Introduce/pdf-viewer.html

  • @furkanguney5871
    @furkanguney5871 Před 11 měsíci

    What is opf.Filter

    • @dineshsthanki
      @dineshsthanki Před 9 měsíci

      That is to inform the fileOpenDialog to only display a list of pdf files from which the user can select the file to view, in the context of this application.

    • @CExercises
      @CExercises  Před 8 měsíci

      Yes but you can change this string: "Pdf File|*.pdf". Before | for text that shows and after | to change the extension.