Back to Devexpress

How to: Load a PDF Document from a File

windowsforms-9832-controls-and-libraries-pdf-viewer-examples-file-operations-how-to-load-a-pdf-document-from-a-file.md

latest1.5 KB
Original Source

How to: Load a PDF Document from a File

  • Jun 20, 2019

The following example illustrates how to load a PDF file into the PdfViewer control. Drop the PdfViewer control onto the form, create a Ribbon via the PdfViewer’s smart tag and call the PdfViewer.LoadDocument method.

View Example

csharp
using System;
using System.Windows.Forms;

namespace PdfViewerSample {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            this.pdfViewer1.LoadDocument(@"..\..\Report.pdf");
        }
    }
}
vb
Imports System
Imports System.Windows.Forms

Namespace PdfViewerSample
    Partial Public Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            Me.pdfViewer1.LoadDocument("..\..\Report.pdf")
        End Sub
    End Class
End Namespace

See Also

How to: Load a PDF Document from a Stream