Articles in this section
Category / Section

How to host WPF PDF Viewer in windows forms?

1 min read

WinForms PDF viewer does not support adding or editing the annotations in PDF documents. As a workaround, the PDF viewer WPF control can be hosted in WF application that supports text markup and shape annotations in the PDF document. Refer to the following code sample.

C#

// Declare the ElementHost variable
        ElementHost elementHost = null;
   // Wire up the Load event
            this.Load += new System.EventHandler(this.Form1_Load);
 
private void Form1_Load(object sender, System.EventArgs e)
        {
            // Create the ElementHost control
            elementHost = new ElementHost();
            elementHost.AutoSize = true;
            elementHost.Size = panel1.Size;
            elementHost.Dock = DockStyle.Fill;
            panel1.Controls.Add(elementHost);
 
            PdfViewer wordEditor = new PdfViewer();
            elementHost.Child = wordEditor;
 
            elementHost.Margin = new Padding(0, 0, 0, 0);
            elementHost.Region = new Region();
            elementHost.BackColor = System.Drawing.Color.White;
        }

Find the sample for your reference from the following link:



Conclusion

I hope you enjoyed learning about how to host PDF Viewer WPF in windows forms.

You can refer to our WinForms PDF Viewer feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms PDF Viewer documentation to understand how to present and manipulate data.

For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms PDF Viewer and other WinForms components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!


Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied