public static async void Save(this C1PdfDocument pdf) { FileSavePicker picker = new FileSavePicker(); picker.FileTypeChoices.Add(Strings.FileTypeChoicesTip, new List <string>() { ".pdf" }); picker.DefaultFileExtension = ".pdf"; picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; StorageFile file = await picker.PickSaveFileAsync(); if (file != null) { await pdf.SaveAsync(file); MessageDialog dlg = new MessageDialog(Strings.SaveLocationTip + " " + file.Path, "PdfSamples"); dlg.Commands.Add(new UICommand("Open", new UICommandInvokedHandler((args) => { // to open the created file (using file extension) var success = Launcher.LaunchFileAsync(file); }))); dlg.Commands.Add(new UICommand("Cancel")); dlg.CancelCommandIndex = 2; await dlg.ShowAsync(); } }
private async void btnSave_Click(object sender, RoutedEventArgs e) { FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; savePicker.FileTypeChoices.Add(Strings.PdfFile, new List <string>() { ".pdf" }); savePicker.DefaultFileExtension = ".pdf"; StorageFile file = await savePicker.PickSaveFileAsync(); if (file != null) { var pdf = new C1PdfDocument(PaperKind.Custom); pdf.ConformanceLevel = PdfAConformanceLevel.PdfA2b; var layout = rtb.ViewManager.PresenterInfo as C1PageLayout; PdfFilter.PrintDocument(rtb.Document, pdf, layout.Padding); await pdf.SaveAsync(file); MessageDialog dlg = new MessageDialog(Strings.SaveMessage + file.Path, Strings.RtbSample); await dlg.ShowAsync(); } }