PdfViewer for WPF and Silverlight Overview > Getting Started > Quick Start > Step 2: Adding PDF Content to the Application |
In the previous step, you created a WPF or Silverlight application and added the C1PdfViewer control to your project. In this step, you add PDF content to the application. You can use a PDF file of your choice to be viewed in the PdfViewer control. The code example given below uses C1XapOptimize.pdf file, which is by default located in the pre-installed folder at the given location.
![]() |
C:\Users\...\Documents\ComponentOne Samples\WPF\C1.WPF.PdfViewer\CS\PdfViewerSamples |
Complete the following steps to add the sample PDF file to your application, and loading the same in the PdfViewer control at runtime.
![]() |
You can also add another PDF file of your choice to be viewed at runtime. |
![]() |
For Silverlight, use the following import statements: Visual Basic - Imports C1.Silverlight.PdfViewer C# - using C1.Silverlight.PdfViewer |
Public Sub New() InitializeComponent() Dim resource = Application.GetResourceStream(New Uri("PDFViewerQuickStartVB;component/C1XapOptimizer.pdf", UriKind.Relative)) Me.C1PdfViewer1.LoadDocument(resource.Stream) End Sub
public MainWindow() { InitializeComponent(); var resource = Application.GetResourceStream(new Uri("PDFViewer_QuickStart;component/C1XapOptimizer.pdf", UriKind.Relative)); this.C1PdfViewer1.LoadDocument(resource.Stream); }
The above code first loads the sample PDF file in a stream, and then loads the stream into the PDFViewer control. Note that if your application and PDF file are named differently, then you need to specify these names in the code.