Рет қаралды 22,626
Find the Visual Studio project and Codes here:
csharp.agrimet...
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