You can easily package an existing PDF file with your application and load it into C1PdfViewer at run time. For example, complete the following steps:
1. Navigate to the Solution Explorer, right-click the project name, and select Add │ New Folder. Name the new folder "Resources".
1. Right-click the Resources folder in the Solution Explorer and select Add │ Existing Item.
1. In the Add Existing Item dialog box, locate a PDF file. 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.
2. In the Solution Explorer, click the PDF file you just added to the application (in this example, we'll assume the file is named MyPdf.pdf). 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.
3. Switch to Code view by double-clicking on the preview in Design view.
4. Add the following imports statement to the top of the page:
Imports C1.Phone.PdfViewer
•
using C1.Phone.PdfViewer;
5. Add the following code to the main class:
Dim resource = Application.GetResourceStream(New Uri("/MyProject;component/Resources/MyPdf.pdf", UriKind.Relative))
C1PdfViewer1.LoadDocument(resource.Stream)
•
var resource = Application.GetResourceStream(new Uri("/MyProject;component/Resources/MyPdf.pdf", UriKind.Relative));
c1PdfViewer1.LoadDocument(resource.Stream);
This code calls the LoadDocument method passing in the application resource stream.
What You've Accomplished
In this example you've loaded a PDF file into the C1PdfViewer from the application resources. You packaged an existing PDF file with your application in code and loaded it into the C1PdfViewer at run time.