You can save and load PDF files to isolated storage using the C1PdfViewer control. To save a file to isolated storage you would need to call the SaveDocument method passing in an isolated storage file stream:
To write the code in Visual Basic:
Visual Basic |
Copy Code
|
---|---|
Public Sub New() InitializeComponent() ' save file to isolated storage Using store = IsolatedStorageFile.GetUserStoreForApplication() Using stream = New IsolatedStorageFileStream("C1XapOptimizer.pdf", FileMode.Create, FileAccess.Write, store) C1PdfViewer1.SaveDocument(stream) End Using End Using End Sub |
To write the code in C#:
C# |
Copy Code
|
---|---|
public MainPage() { InitializeComponent(); // load file from the Web WebClient client = new WebClient(); client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted); client.OpenReadAsync(new Uri("http://www.componentone.com/newimages/Products/Documentation/Silverlight.Maps.pdf", UriKind.Absolute)); } void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { c1PdfViewer1.LoadDocument(e.Result); |
•
public MainPage()
{
InitializeComponent();
// save file to isolated storage
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var stream = new IsolatedStorageFileStream("C1XapOptimizer.pdf", FileMode.Create, FileAccess.Write, store))
{
c1PdfViewer1.SaveDocument(stream);
}
}
}
To load an existing file from isolated storage call the LoadDocument method passing in an isolated storage file stream:
•
public MainPage()
{
InitializeComponent();
// load file from isolated storage
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var stream = new IsolatedStorageFileStream("C1XapOptimizer.pdf", FileMode.OpenOrCreate, FileAccess.Read, store))
{
c1PdfViewer1.LoadDocument(stream);
}
}
}
What You've Accomplished
In this example you've saved and loaded PDF files to isolated storage using the C1PdfViewer control.