Step 2 of 3: Adding Content to the C1PdfViewer Control

In the previous step you created a Silverlight application and added the C1PdfViewer control to your project. In this step you'll add PDF content to the C1PdfViewer control. Note that in this step you will add a PDF file that is included with the ComponentOne Studio for Silverlight samples, which are by default installed in the Documents or MyDocuments folder in the ComponentOne Samples\Studio for Silverlight 4.0\C1.Silverlight.PdfViewer\PdfViewerSamples directory. If you choose, you can instead use another PDF file and adapt the steps. To customize your project and add a PDF file to the C1PdfViewer control in your application, complete the following steps:

1.   Navigate to the Solution Explorer, right-click the project name, and select Add │ Existing Item.

2.   In the Add Existing Item dialog box, locate the C1XapOptimizer.pdf file included in the ControlExplorer sample. In the file type drop-down box, you may need to choose All Files to view the PDF file. Note that if you choose, you can instead pick another PDF file to use.

3.   In the Solution Explorer, click the PDF file you just added to the application. In the Properties window, set its BuildAction property to Resource and confirm that the Copy to Output Directory item is set to Do not Copy.

4.   Switch to Code view by right-clicking the page and selecting View Code.

5.   Add the following imports statement at the top of the page:

      Visual Basic

      C#

6.   Add the following code to the main class :

      Visual Basic

      C#

This code adds a stream and loads the stream into the C1PdfViewer control. Note that if you named the application differently, you will need to replace "QuickStart" with the name of your project. If you added a different PDF file, replace "C1XapOptimizer.pdf" with the name of your file.

If you run the application now, it will appear in the content window within the C1PdfViewer control:

 

 

In this step you added content to the C1PdfViewer control. In the next step you'll view some of the run-time interactions possible in the control.


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.