public ActionResult MergingPresentation(string Group1, string Group2) { if (Group1 == null) { return(View()); } Stream sourceFile = new FileStream(ResolveApplicationDataPath(@"..\Presentation\MergeContent.pptx"), FileMode.Open, FileAccess.Read, FileShare.Read); IPresentation sourcePresentation = Presentation.Open(sourceFile); Stream destinationFile = new FileStream(ResolveApplicationDataPath(@"..\Presentation\Essential Presentation.pptx"), FileMode.Open, FileAccess.Read, FileShare.Read); IPresentation destinationPresentation = Presentation.Open(destinationFile); ISlides slides = sourcePresentation.Slides; if (Group1 == "DestinationTheme") { //Adding the cloned slide to the destination presentation by using Destination option. foreach (ISlide slide in slides) { destinationPresentation.Slides.Add(slide, PasteOptions.UseDestinationTheme, sourcePresentation); } return(new PresentationResult(destinationPresentation, "MergedUsingDestination.pptx", HttpContext.ApplicationInstance.Response)); } else { foreach (ISlide slide in slides) { //Adding the cloned slide to the destination presentation by using Destination option. destinationPresentation.Slides.Add(slide, PasteOptions.SourceFormatting, sourcePresentation); } return(new PresentationResult(destinationPresentation, "MergedUsingSource.pptx", HttpContext.ApplicationInstance.Response)); } }
private void btnMergeDocument_Click(object sender, EventArgs e) { try { if (this.radioDestination.IsChecked == true) { //Creates instance for source presentation IPresentation sourcePresentation = Presentation.Open(txtFile1.Tag.ToString()); //Creates instance for destination presentation IPresentation destinationPresentation = Presentation.Open(txtFile.Tag.ToString()); ISlides slides = sourcePresentation.Slides; foreach (ISlide slide in slides) { //Clones the slides from source to destination destinationPresentation.Slides.Add(slide.Clone(), PasteOptions.UseDestinationTheme, sourcePresentation); } //Closing the Source presentation sourcePresentation.Close(); //Saving the Destination presentaiton. destinationPresentation.Save("MergedUsingDestination.pptx"); destinationPresentation.Close(); if (System.Windows.MessageBox.Show("Do you want to view the merged PowerPoint Presentation?", "Finished Merging", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { System.Diagnostics.Process.Start("MergedUsingDestination.pptx"); } } else { //Creates instance for source presentation IPresentation sourcePresentation = Presentation.Open(txtFile1.Tag.ToString()); //Creates instance for destination presentation IPresentation destinationPresentation = Presentation.Open(txtFile.Tag.ToString()); ISlides slides = sourcePresentation.Slides; foreach (ISlide slide in slides) { //Clones the slides from source to destination destinationPresentation.Slides.Add(slide.Clone(), PasteOptions.SourceFormatting, sourcePresentation); } //Closing the Source presentation sourcePresentation.Close(); //Saving the Destination presentaiton. destinationPresentation.Save("MergedUsingSource.pptx"); //Closing the destination presentation destinationPresentation.Close(); if (System.Windows.MessageBox.Show("Do you want to view the merged PowerPoint Presentation?", "Finished Merging", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { System.Diagnostics.Process.Start("MergedUsingSource.pptx"); } } } catch (Exception exp) { MessageBox.Show("This file could not be merged, please contact Syncfusion Direct-Trac system at http://www.syncfusion.com/support/default.aspx for any queries. ", "OOPS..Sorry!", MessageBoxButton.OK); this.Close(); } }
protected void btnMergeDocuments_Click(object sender, EventArgs e) { if (this.FileUpload1.HasFile && this.FileUpload2.HasFile) { string source = Path.GetFileNameWithoutExtension(this.FileUpload1.PostedFile.FileName); string destination = Path.GetFileNameWithoutExtension(this.FileUpload2.PostedFile.FileName); string extSource = Path.GetExtension(this.FileUpload1.PostedFile.FileName).ToLower(); string extDestination = Path.GetExtension(this.FileUpload2.PostedFile.FileName).ToLower(); if (extSource == ".pptx" && extDestination == ".pptx") { //Convert the input powerpoint document to a PDF file # region Clone Slide using Destination Theme Stream readSource = this.FileUpload1.PostedFile.InputStream; Stream readDestination = this.FileUpload2.PostedFile.InputStream; try { //Opens the specified presentation IPresentation sourcePresentation = Presentation.Open(readSource); IPresentation destinationPresentation = Presentation.Open(readDestination); ISlides slides = sourcePresentation.Slides; if (this.RadioDestination.Checked == true) { foreach (ISlide slide in slides) { destinationPresentation.Slides.Add(slide.Clone(), PasteOptions.UseDestinationTheme, sourcePresentation); } //Closing the Source presentation sourcePresentation.Close(); readSource.Close(); //Saving the Destination presentaiton. destinationPresentation.Save("MergedUsingDestination.pptx", FormatType.Pptx, Response); } else { foreach (ISlide slide in slides) { destinationPresentation.Slides.Add(slide.Clone(), PasteOptions.SourceFormatting, sourcePresentation); } //Closing the Source presentation sourcePresentation.Close(); readSource.Close(); //Saving the Destination presentaiton. destinationPresentation.Save("MergedUsingSource.pptx", FormatType.Pptx, Response); } } catch (Exception) { this.label1.Text = "The input document could not be processed, Could you please email the document to [email protected] for troubleshooting"; } # endregion } else { this.label1.Text = "Please choose pptx file to perform merging"; } }