| PdfViewer for WPF and Silverlight Overview > PdfViewer Features > Loading Documents |
To open an existing PDF file you can use the LoadDocument method by passing a stream to the file. To open a file selected by the user, complete the following code:
| Visual Basic |
Copy Code
|
|---|---|
Dim openPicker As New FileOpenPicker() openPicker.FileTypeFilter.Add(".pdf") Dim file As StorageFile = Await openPicker.PickSingleFileAsync() If file IsNot Nothing Then Dim stream As Stream = Await file.OpenStreamForReadAsync() pdfViewer.LoadDocument(stream) End If |
|
| C# |
Copy Code
|
|---|---|
FileOpenPicker openPicker = new FileOpenPicker(); openPicker.FileTypeFilter.Add(".pdf"); StorageFile file = await openPicker.PickSingleFileAsync(); if (file != null) { Stream stream = await file.OpenStreamForReadAsync(); pdfViewer.LoadDocument(stream); } |
|