PDF Viewer in Windows Forms

We are currently in the process of evaluating PDFTRON in a C# / Visual Studio 2019 / Windows Forms / .NET environment. One of the task we have to accomplish to successfully accomplish the evaluation is to use the PDF Viewer class within PDFTRON to display and manipulate existing PDF files.

Our intention is to use the Viewer as one of the controls being displayed on a Windows Form. It seems to me that there is no way to integrate the viewer in the Visual Studio 2019 toolbox which would allow us to place it during the Form’s design time and to assign it the desired position ad size within the form.

So instead we have tried to integrate it into the form during runtime using the following code:

            doc = new PDFDoc(PdfFileName);
            _pdfview.Parent = panelControl1;
            _pdfview.Location = new System.Drawing.Point(0, 0);
            _pdfview.Dock = System.Windows.Forms.DockStyle.Fill;
            _pdfview.SetPageBorderVisibility(true);
            Controls.Add(_pdfview);
            _pdfview.SetDoc(doc);
            _pdfview.Show();

This code will be executed without any error messages but we don’t see the Viewer within the form.

So please let me ask which way we should use to place the viewer on a form’s surface in case some controls have already been places there during design time. It also would be interesting to us if it’s possible to integrate the PDFTRON Viewer into the Visual Studio Tools sidebar.

Deu to the fact that the Form may have differnt sizes when being run on differerent systems, we assume it’s inappropriate to use fixed screen coordinates to assign position and size to the viewer. We’d rather like to use the notion of specifying a parant control on the form’s surface whose space might be fully filled up (used) by the viewer control.

Thank you for your help

Alex

Regarding the viewer not showing anything, please take a look at our PDFViewSimpleTest sample, which is simple sample showing PDFViewCtrl used with WinForms.

As for the VisualStudio Toolbox, since PDFViewCtrl inherits from Control, I believe you can add it to your Toolbox, following steps like this.

  1. Right click in Toolbox and select “Add Tab”
  2. Name as PDFTron
  3. Drag the PDFNet.dll from Windows Explorer into the tab area in the toolbox.

thanks for the awesome information.