private async void OnDeserializeDataGrid(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { var folder = ApplicationData.Current.LocalFolder; try { var storageFile = await folder.GetFileAsync("DataGrid.xml"); var options = new DeserializationOptions() { DeserializeColumns = (bool)this.DeserializeColumns.IsChecked, DeserializeFiltering = (bool)this.DeserializeFiltering.IsChecked, DeserializeSorting = (bool)this.DeserializeSorting.IsChecked, DeserializeGrouping = (bool)this.DeserializeGrouping.IsChecked, DeserializeGroupSummaries = (bool)this.DeserializeGroupSummaries.IsChecked, DeserializeTableSummaries = (bool)this.DeserializeTableSummaries.IsChecked, DeserializeStackedHeaders = (bool)this.DeserializeStackedHeaders.IsChecked }; this.sfDataGrid.Deserialize(storageFile, options); } catch (Exception) { } }
/// <summary> /// Set the default value for paste option /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PasteOptionListBox_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { PasteOptionListBox.SelectedIndex = 1; }
private void MyImageButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { ShowMenu((sender as Button).IsPointerOver); }
private async void AddButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { var dialog = new MessageDialog("Adding items to the collection is not yet available.", "My Media Collection"); await dialog.ShowAsync(); }
/// <summary> /// Performs Mail merge for nested groups in Word document. /// </summary> private void Button_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { //Gets the input Word document. string basePath = "syncfusion.dociodemos.winui.Assets.DocIO."; string dataPath = basePath + @"TemplateLetter.docx"; //Creates a new Word document instance. using WordDocument document = new(); Stream fileStream = assembly.GetManifestResourceStream(dataPath); //Opens an existing Word document. document.Open(fileStream, FormatType.Doc); fileStream.Dispose(); //Inserts page break at last paragraph, to populate each employee details in new page. Break pageBreak = new(document, BreakType.PageBreak); document.LastParagraph.ChildEntities.Insert(0, pageBreak); #region Execute Mail merge MailMergeDataSet dataSet = GetMailMergeDataSet(basePath); List <DictionaryEntry> commands = new(); //DictionaryEntry contain "Source table" (KEY) and "Command" (VALUE) DictionaryEntry entry = new("Employees", string.Empty); commands.Add(entry); //Retrives customer details. entry = new DictionaryEntry("Customers", "EmployeeID = %Employees.EmployeeID%"); commands.Add(entry); //Retrives order details. entry = new DictionaryEntry("Orders", "CustomerID = %Customers.CustomerID%"); commands.Add(entry); //Executes nested Mail merge using explicit relational data. document.MailMerge.ExecuteNestedGroup(dataSet, commands); #endregion //Clears the items (Page break) in last paragraph to remove empty page after execution. document.LastParagraph.ChildEntities.Clear(); #region Document SaveOption using MemoryStream ms = new(); string filename = string.Empty; //Saves as .docx format. if (worddocx.IsChecked == true) { filename = "Orders Report.docx"; //Saves the Word document to the memory stream. document.Save(ms, FormatType.Docx); } //Saves as .doc format. else if (worddoc.IsChecked == true) { filename = "Orders Report.doc"; //Saves the Word document to the memory stream. document.Save(ms, FormatType.Doc); } //Saves as .pdf format. else if (pdf.IsChecked == true) { filename = "Orders Report.pdf"; //Creates a new DocIORenderer instance. using DocIORenderer renderer = new(); //Converts Word document into PDF. using PdfDocument pdfDoc = renderer.ConvertToPDF(document); //Saves the PDF document to the memory stream. pdfDoc.Save(ms); } ms.Position = 0; //Saves the memory stream as file. SaveHelper.SaveAndLaunch(filename, ms); #endregion Document SaveOption }
private void Setting_Checked(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { // Apply display settings UpdateDisplaySettings(); }
private void SfTreeGrid_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { this.sfTreeGrid.RequestTreeItems += treeGrid_RequestChildSource; this.sfTreeGrid.RepopulateTree(); }
private async void BugReportButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { await NavigationService.OpenInBrowser("https://github.com/yoshiask/FluentStore/issues/new"); }
private async void DonateButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { await NavigationService.OpenInBrowser("http://josh.askharoun.com/donate"); }
/// <summary> /// Add table in a PowerPoint Presentation file. /// </summary> private void BtnCreatePresn_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { //Creates a new instance of the PowerPoint Presentation file. using IPresentation presentation = Syncfusion.Presentation.Presentation.Create(); #region Slide1 //Adds a slide to PowerPoint presentation. ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleOnly); //Sets the table title in a slide. SetTableTitle(slide); //Gets table data from xml file. DataSet dataSet = new(); Assembly assembly = typeof(Table).GetTypeInfo().Assembly; string resourcePath = "syncfusion.presentationdemos.winui.Assets.Presentation.TableData.xml"; using (Stream fileStream = assembly.GetManifestResourceStream(resourcePath)) { dataSet.ReadXml(fileStream); } int columnCount = dataSet.Tables[0].Rows.Count + 1; int rowCount = dataSet.Tables.Count - 1; //Adds a new table in slide. ITable table = slide.Shapes.AddTable(rowCount, columnCount, 61.92, 95.76, 856.8, 378.72); //Sets the style for the table. table.BuiltInStyle = BuiltInTableStyle.MediumStyle2Accent6; //Sets category title SetCategoryTitle(table); //Iterates and sets the values to the table cells. for (int rowIndex = 0; rowIndex < table.Rows.Count; rowIndex++) { IRow row = table.Rows[rowIndex]; if (rowIndex == 0) { AddHeaderRow(row, dataSet.Tables[0].Rows); } else { AddCell(row, dataSet.Tables[rowIndex + 1]); } } #endregion //Saves the presentation to the memory stream. using MemoryStream stream = new(); if (presentationdoc.IsChecked == true) { presentation.Save(stream); stream.Position = 0; //Saves the memory stream as file. SaveAndLaunch.Save("Table.pptx", stream); } else { //Converts the PowerPoint Presentation to PDF document. using (PdfDocument pdfDocument = PresentationToPdfConverter.Convert(presentation)) { //Saves the converted PDF document to MemoryStream. pdfDocument.Save(stream); stream.Position = 0; } //Saves the memory stream as file. SaveAndLaunch.Save("Table.pdf", stream); } }
private void ClearCacheButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { DownloadCache cache = new(createIfDoesNotExist : false); cache.Clear(); }
/// <summary> /// Set the default value for copy option /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CopyList_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { CopyList.SelectedIndex = 1; }
private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { ViewModel.OnNavigatedTo(null, null); }
private void UpdateObserverWithCamera(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { // Use the current camera to update the observer for the location viewshed analysis. _viewshedForCamera.UpdateFromCamera(MySceneView.Camera); }
private void OnUnloaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { ViewModel.RightPaneService.CleanUp(); }
private async void Page_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { await Reload(); }
/// <summary> /// Inserts images into the Word document. /// </summary> private void Button_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { //Creates a new Word document. using WordDocument document = new(); //Adds a new section to the document. IWSection section = document.AddSection(); section.PageSetup.Margins.All = 72; //Adds a paragraph to the section. IWParagraph paragraph = section.AddParagraph(); //Writes the text. paragraph.AppendText("This sample demonstrates how to insert images in a Word document."); //Adds a new paragraph. paragraph = section.AddParagraph(); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; paragraph.ParagraphFormat.BeforeSpacing = 12f; Assembly assembly = typeof(ImageInsertion).GetTypeInfo().Assembly; string basePath = "syncfusion.dociodemos.winui.Assets.DocIO."; Stream imageStream = assembly.GetManifestResourceStream(basePath + "AdventureCycle.png"); //Inserts .png image. WPicture picture = (WPicture)paragraph.AppendPicture(imageStream); //Scales the Image. picture.HeightScale = 25f; picture.WidthScale = 25f; //Adds Image caption. picture.AddCaption("Figure", CaptionNumberingFormat.Roman, CaptionPosition.AfterImage); ApplyFormattingForCaption(document.LastParagraph); //Inserts .jpg image. paragraph = section.AddParagraph(); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; imageStream = assembly.GetManifestResourceStream(basePath + "Mountain200.jpg"); picture = (WPicture)paragraph.AppendPicture(imageStream); //Adds Image caption. picture.AddCaption("Figure", CaptionNumberingFormat.Roman, CaptionPosition.AfterImage); ApplyFormattingForCaption(document.LastParagraph); //Inserts .bmp image. paragraph = section.AddParagraph(); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; imageStream = assembly.GetManifestResourceStream(basePath + "Mountain300.bmp"); picture = (WPicture)paragraph.AppendPicture(imageStream); //Adds Image caption. picture.AddCaption("Figure", CaptionNumberingFormat.Roman, CaptionPosition.AfterImage); ApplyFormattingForCaption(document.LastParagraph); //Inserts .jpg image. paragraph = section.AddParagraph(); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; imageStream = assembly.GetManifestResourceStream(basePath + "Road550W.jpg"); picture = (WPicture)paragraph.AppendPicture(imageStream); //Adds Image caption. picture.AddCaption("Figure", CaptionNumberingFormat.Roman, CaptionPosition.AfterImage); ApplyFormattingForCaption(document.LastParagraph); //Updates the fields in Word document. document.UpdateDocumentFields(); #region Document SaveOption using MemoryStream ms = new(); string filename = string.Empty; //Saves as .docx format. if (worddocx.IsChecked == true) { filename = "Image Insertion.docx"; //Saves the Word document to the memory stream. document.Save(ms, FormatType.Docx); } //Saves as .doc format. else if (worddoc.IsChecked == true) { filename = "Image Insertion.doc"; //Saves the Word document to the memory stream. document.Save(ms, FormatType.Doc); } //Saves as .pdf format. else if (pdf.IsChecked == true) { filename = "Image Insertion.pdf"; //Creates a new DocIORenderer instance. using DocIORenderer renderer = new(); //Converts Word document into PDF. using PdfDocument pdfDoc = renderer.ConvertToPDF(document); //Saves the PDF document to the memory stream. pdfDoc.Save(ms); } ms.Position = 0; //Saves the memory stream as file. SaveHelper.SaveAndLaunch(filename, ms); #endregion Document SaveOption }
private void SmallImage_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { SmallImage.Source = ImageSource; }
private void OpenColorsSettings_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { Helpers.StartProcessHelper.Start(Helpers.StartProcessHelper.ColorsSettings); }
private void BackButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { Frame.GoBack(); }
private void MainPage_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { ItemFilter.SelectionChanged += ItemFilter_SelectionChanged; PopulateData(); }
private void ItemList_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { var listView = (ListView)sender; listView.ItemsSource = _items; }
private void CancelClick(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { // Hide entry UI. MyMapView.IsEnabled = true; AttributesBorder.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed; }
/// <summary> /// Inserts and updates the Table of Contents (TOC) in a Word document. /// </summary> private void Button_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { //Creates a new Word document. using WordDocument document = new(); //Adds one section and paragraph. document.EnsureMinimal(); document.LastSection.PageSetup.Margins.All = 72; WParagraph para = document.LastParagraph; IWTextRange textRange = para.AppendText("Essential DocIO - Table of Contents"); textRange.CharacterFormat.Bold = true; textRange.CharacterFormat.FontSize = 14; para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; para.ParagraphFormat.BeforeSpacing = 12f; para.ParagraphFormat.AfterSpacing = 3f; para = document.LastSection.AddParagraph() as WParagraph; para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; para.ParagraphFormat.BeforeSpacing = 12f; para.ParagraphFormat.AfterSpacing = 3f; if (!checkBox.IsChecked.Value) { textRange = para.AppendText("Select TOC and press F9 to update the Table of Contents"); textRange.CharacterFormat.HighlightColor = Syncfusion.Drawing.Color.Yellow; textRange.CharacterFormat.Bold = true; textRange.CharacterFormat.FontSize = 14; } para = document.LastSection.AddParagraph() as WParagraph; //Inserts TOC. Syncfusion.DocIO.DLS.TableOfContent toc = para.AppendTOC(1, 3); para.ParagraphFormat.BeforeSpacing = 12f; para.ParagraphFormat.AfterSpacing = 3f; //Applies built-in paragraph formatting. WSection section = document.LastSection; #region Default Styles WParagraph newPara = section.AddParagraph() as WParagraph; newPara = section.AddParagraph() as WParagraph; newPara.AppendBreak(BreakType.PageBreak); WTextRange text = newPara.AppendText("Document with Default styles") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading1); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading1 of built in style. This sample demonstrates the TOC insertion in a word document. Note that DocIO can only insert TOC field in a word document. It can not refresh or create TOC field. MS Word refreshes the TOC field after insertion. Please update the field or press F9 key to refresh the TOC."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Section1") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading2); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading2 of built in style. A document can contain any number of sections. Sections are used to apply same formatting for a group of paragraphs. You can insert sections by inserting section breaks."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph1") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. Each section contains any number of paragraphs. A paragraph is a set of statements that gives a meaning for the text."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph2") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. This demonstrates the paragraphs at the same level and style as that of the previous one. A paragraph can have any number formatting. This can be attained by formatting each text range in the paragraph."); section.AddParagraph(); section = document.AddSection() as WSection; section.PageSetup.Margins.All = 72; section.BreakCode = SectionBreakCode.NewPage; newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Section2") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading2); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading2 of built in style. A document can contain any number of sections. Sections are used to apply same formatting for a group of paragraphs. You can insert sections by inserting section breaks."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph1") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. Each section contains any number of paragraphs. A paragraph is a set of statements that gives a meaning for the text."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph2") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. This demonstrates the paragraphs at the same level and style as that of the previous one. A paragraph can have any number formatting. This can be attained by formatting each text range in the paragraph."); #endregion //Enables a flag to show page numbers in table of contents. toc.IncludePageNumbers = true; //Enables a flag to show page numbers as right aligned. toc.RightAlignPageNumbers = true; //Enables a flag to use hyperlinks for the levels. toc.UseHyperlinks = true; //Sets the starting heading level of the table of contents. toc.LowerHeadingLevel = 1; //Sets the ending heading level of the table of contents. toc.UpperHeadingLevel = 3; //Enables a flag to use outline levels. toc.UseOutlineLevels = true; //Updates the table of contents. if (checkBox.IsChecked.Value) { document.UpdateTableOfContents(); } #region Document SaveOption using MemoryStream ms = new(); string filename = string.Empty; //Saves as .docx format. if (worddocx.IsChecked == true) { filename = "Table of Contents.docx"; //Saves the Word document to the memory stream. document.Save(ms, FormatType.Docx); } //Saves as .doc format. else if (worddoc.IsChecked == true) { filename = "Table of Contents.doc"; //Saves the Word document to the memory stream. document.Save(ms, FormatType.Doc); } //Saves as .pdf format. else if (pdf.IsChecked == true) { filename = "Table of Contents.pdf"; //Creates a new DocIORenderer instance. using DocIORenderer renderer = new(); //Converts Word document into PDF. using PdfDocument pdfDoc = renderer.ConvertToPDF(document); //Saves the PDF document to the memory stream. pdfDoc.Save(ms); } ms.Position = 0; //Saves the memory stream as file. SaveHelper.SaveAndLaunch(filename, ms); #endregion Document SaveOption }
private void OnElementClicked(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { // Do custom logic SelectedOptionText.Text = "You clicked: " + (sender as AppBarButton).Label; }
private async void TakeMapOfflineButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { // Create a new folder for the output mobile map. string packagePath = Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), @"NapervilleWaterNetwork"); int num = 1; while (Directory.Exists(packagePath)) { packagePath = Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), @"NapervilleWaterNetwork" + num.ToString()); num++; } // Create the output directory. Directory.CreateDirectory(packagePath); try { // Show the progress indicator while the job is running. BusyIndicator.Visibility = Microsoft.UI.Xaml.Visibility.Visible; // Create an offline map task with the current (online) map. OfflineMapTask takeMapOfflineTask = await OfflineMapTask.CreateAsync(MyMapView.Map); // Create the default parameters for the task, pass in the area of interest. GenerateOfflineMapParameters parameters = await takeMapOfflineTask.CreateDefaultGenerateOfflineMapParametersAsync(_areaOfInterest); // Configure basemap settings for the job. await ConfigureOfflineJobForBasemap(parameters); // Create the job with the parameters and output location. _generateOfflineMapJob = takeMapOfflineTask.GenerateOfflineMap(parameters, packagePath); // Handle the progress changed event for the job. _generateOfflineMapJob.ProgressChanged += OfflineMapJob_ProgressChanged; // Await the job to generate geodatabases, export tile packages, and create the mobile map package. GenerateOfflineMapResult results = await _generateOfflineMapJob.GetResultAsync(); // Check for job failure (writing the output was denied, e.g.). if (_generateOfflineMapJob.Status != JobStatus.Succeeded) { var dialog = new MessageDialog2("Generate offline map package failed.", "Job status"); await dialog.ShowAsync(); BusyIndicator.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed; } // Check for errors with individual layers. if (results.LayerErrors.Any()) { // Build a string to show all layer errors. System.Text.StringBuilder errorBuilder = new System.Text.StringBuilder(); foreach (KeyValuePair <Layer, Exception> layerError in results.LayerErrors) { errorBuilder.AppendLine($"{layerError.Key.Id} : {layerError.Value.Message}"); } // Show layer errors. string errorText = errorBuilder.ToString(); var dialog = new MessageDialog2(errorText, "Layer errors"); await dialog.ShowAsync(); } // Display the offline map. MyMapView.Map = results.OfflineMap; // Apply the original viewpoint for the offline map. MyMapView.SetViewpoint(new Viewpoint(_areaOfInterest)); // Enable map interaction so the user can explore the offline data. MyMapView.InteractionOptions.IsEnabled = true; // Hide the "Take map offline" button. TakeOfflineArea.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed; // Show a message that the map is offline. MessageArea.Visibility = Microsoft.UI.Xaml.Visibility.Visible; } catch (TaskCanceledException) { // Generate offline map task was canceled. var dialog = new MessageDialog2("Taking map offline was canceled"); await dialog.ShowAsync(); } catch (Exception ex) { // Exception while taking the map offline. var dialog = new MessageDialog2(ex.Message, "Offline map error"); await dialog.ShowAsync(); } finally { // Hide the activity indicator when the job is done. BusyIndicator.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed; } }
/// <summary> /// Creates a simple Word document with text, image and table. /// </summary> private void Button_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { //Creates a new Word document. using WordDocument document = new(); //Adds a new section to the document. WSection section = document.AddSection() as WSection; //Sets margin of the section. section.PageSetup.Margins.All = 72; //Sets page size of the section. section.PageSetup.PageSize = new SizeF(612, 792); //Creates normal paragraph styles. WParagraphStyle style = document.AddParagraphStyle("Normal") as WParagraphStyle; style.CharacterFormat.FontName = "Calibri"; style.CharacterFormat.FontSize = 11f; style.ParagraphFormat.BeforeSpacing = 0; style.ParagraphFormat.AfterSpacing = 8; style.ParagraphFormat.LineSpacing = 13.8f; //Creates heading paragraph style. style = document.AddParagraphStyle("Heading 1") as WParagraphStyle; style.ApplyBaseStyle("Normal"); style.CharacterFormat.FontName = "Calibri Light"; style.CharacterFormat.FontSize = 16f; style.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(46, 116, 181); style.ParagraphFormat.BeforeSpacing = 12; style.ParagraphFormat.AfterSpacing = 0; style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1; //Creates paragraph in the Word document. CreateParagraph(section); //Creates product overview table in the Word document. CreateProductOverviewTable(section); #region Document SaveOption using MemoryStream ms = new(); string filename = string.Empty; //Saves as .docx format. if (worddocx.IsChecked == true) { filename = "Hello World.docx"; //Saves the Word document to the memory stream. document.Save(ms, FormatType.Docx); } //Saves as .doc format. else if (worddoc.IsChecked == true) { filename = "Hello World.doc"; //Saves the Word document to the memory stream. document.Save(ms, FormatType.Doc); } //Saves as .pdf format. else if (pdf.IsChecked == true) { filename = "Hello World.pdf"; //Creates a new DocIORenderer instance. using DocIORenderer renderer = new(); //Converts Word document into PDF. using PdfDocument pdfDoc = renderer.ConvertToPDF(document); //Saves the PDF document to the memory stream. pdfDoc.Save(ms); } ms.Position = 0; //Saves the memory stream as file. SaveHelper.SaveAndLaunch(filename, ms); #endregion Document SaveOption }
private void CancelJobButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { // The user canceled the job. _generateOfflineMapJob.Cancel(); }
/// <summary> /// Converts Word document to PDF. /// </summary> private void Button_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { //Gets the input Word document. string resourcePath = "syncfusion.dociodemos.winui.Assets.DocIO.WordtoPDF.docx"; using Stream fileStream = assembly.GetManifestResourceStream(resourcePath); //Loads an existing Word document. using WordDocument document = new(fileStream, FormatType.Automatic); //Creates a new DocIORenderer instance. using DocIORenderer render = new(); //Enables a flag to preserve document structured tags in the converted tagged PDF. if (checkBox1.IsChecked == true) { render.Settings.AutoTag = true; } //Enables a flag to preserve the Word document form field as editable PDF form field in PDF document. if (checkBox2.IsChecked == true) { render.Settings.PreserveFormFields = true; } //Sets ExportBookmarks for preserving Word document headings as PDF bookmarks. if (checkBox3.IsChecked == true) { render.Settings.ExportBookmarks = Syncfusion.DocIO.ExportBookmarkType.Headings; } #region Preserve track changes in PDF if (checkBox4.IsChecked == true) { //Enables to show the revision marks in the generated PDF for tracked changes or revisions in the Word document. document.RevisionOptions.ShowMarkup = RevisionType.Deletions | RevisionType.Formatting | RevisionType.Insertions; //Sets revision bars color as Black. document.RevisionOptions.RevisionBarsColor = RevisionColor.Black; //Sets revised properties (Formatting) color as Blue. document.RevisionOptions.RevisedPropertiesColor = RevisionColor.Blue; //Sets deleted text (Deletions) color as Yellow. document.RevisionOptions.DeletedTextColor = RevisionColor.Yellow; //Sets inserted text (Insertions) color as Pink. document.RevisionOptions.InsertedTextColor = RevisionColor.Pink; } #endregion #region Preserve comments in PDF if (checkBox5.IsChecked == true) { //Sets ShowInBalloons to render a document comments in converted PDF document. document.RevisionOptions.CommentDisplayMode = CommentDisplayMode.ShowInBalloons; //Sets the color to be used for Comment Balloon. document.RevisionOptions.CommentColor = RevisionColor.Blue; } #endregion //Converts Word document into PDF. using PdfDocument pdfDocument = render.ConvertToPDF(document); using MemoryStream ms = new(); //Saves the converted PDF document to the memory stream. pdfDocument.Save(ms); ms.Position = 0; //Saves the memory stream as file. SaveHelper.SaveAndLaunch("WordtoPDF.pdf", ms); }
/// <summary> /// Appends bookmarks into the Word document. /// </summary> private void Button_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { //Creates a new Word document. using WordDocument document = new(); //Adds a section to the document. IWSection section = document.AddSection(); //Adds a new paragraph to the section. IWParagraph paragraph = section.AddParagraph(); //Appends text. paragraph.AppendText("This document demonstrates Essential DocIO's Bookmark functionality.").CharacterFormat.FontSize = 14f; //Adds paragraph to the section. section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.AppendText("1. Inserting Bookmark Text").CharacterFormat.FontSize = 12f; //Adds paragraph to the section. section.AddParagraph(); paragraph = section.AddParagraph(); #region Bookmark Creation //Appends BookmarkStart. paragraph.AppendBookmarkStart("Bookmark"); //Appends text. paragraph.AppendText("Bookmark Text"); //Appends BookmarkEnd. paragraph.AppendBookmarkEnd("Bookmark"); //Adds paragraph to the section. section.AddParagraph(); paragraph = section.AddParagraph(); //Indicates hidden bookmark text start. paragraph.AppendBookmarkStart("_HiddenText"); //Appends bookmark text. paragraph.AppendText("2. Hidden Bookmark Text").CharacterFormat.Font = new Syncfusion.Drawing.Font("Comic Sans MS", 10); //Indicates hidden bookmark text end. paragraph.AppendBookmarkEnd("_HiddenText"); section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.AppendText("3. Nested Bookmarks").CharacterFormat.FontSize = 12f; //Appends nested bookmarks. section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.AppendBookmarkStart("Main"); paragraph.AppendText(" Main data "); paragraph.AppendBookmarkStart("Nested"); paragraph.AppendText(" Nested data "); paragraph.AppendBookmarkStart("NestedNested"); paragraph.AppendText(" Nested Nested "); paragraph.AppendBookmarkEnd("NestedNested"); paragraph.AppendText(" data Nested "); paragraph.AppendBookmarkEnd("Nested"); paragraph.AppendText(" Data Main "); paragraph.AppendBookmarkEnd("Main"); #endregion Bookmark Creation #region Document SaveOption using MemoryStream ms = new(); string filename = string.Empty; //Saves as .docx format. if (worddocx.IsChecked == true) { filename = "Bookmarks.docx"; //Saves the Word document to the memory stream. document.Save(ms, FormatType.Docx); } //Saves as .doc format. else if (worddoc.IsChecked == true) { filename = "Bookmarks.doc"; //Saves the Word document to the memory stream. document.Save(ms, FormatType.Doc); } //Saves as .pdf format. else if (pdf.IsChecked == true) { filename = "Bookmarks.pdf"; //Creates a new DocIORenderer instance. using DocIORenderer renderer = new(); //Converts Word document into PDF. using PdfDocument pdfDoc = renderer.ConvertToPDF(document); //Saves the PDF document to the memory stream. pdfDoc.Save(ms); } ms.Position = 0; //Saves the memory stream as file. SaveHelper.SaveAndLaunch(filename, ms); #endregion Document SaveOption }