示例#1
0
        public static void CompareTablesFromDifferentPresentations()
        {
            string sourcePath =
                @"GroupDocs.Comparison.Samples.Slides.Components.data.CompareTablesFromDifferentPresentations.old.pptx";
            string targetPath =
                @"GroupDocs.Comparison.Samples.Slides.Components.data.CompareTablesFromDifferentPresentations.new.pptx";

            // Create to streams of presentations
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   sourceStream = assembly.GetManifestResourceStream(sourcePath);
            Stream   targetStream = assembly.GetManifestResourceStream(targetPath);

            // Opening two presentations
            ComparisonPresentationBase sourcePresentation = new ComparisonPresentation(sourceStream);

            Console.WriteLine("Presentation with source path: " + sourcePath + " was loaded.");
            ComparisonPresentationBase targetPresentation = new ComparisonPresentation(targetStream);

            Console.WriteLine("Presentation with source path: " + targetPath + " was loaded.");

            // Getting first Table from source presentation
            ComparisonTableBase sourceTable = (sourcePresentation.Slides[0].Shapes[0] as ComparisonTableBase);
            // Getting first Table from target presentation
            ComparisonTableBase targetTable = (targetPresentation.Slides[0].Shapes[0] as ComparisonTableBase);

            // Creating settings for comparison of Tables
            SlidesComparisonSettings SlidesComparisonSettings = new SlidesComparisonSettings();
            // Comparing Tables
            ISlidesCompareResult compareResult = sourceTable.CompareWith(targetTable, SlidesComparisonSettings);

            Console.WriteLine("Tables was compared.");

            // Saving result of comparison to new presentation
            string resultPath = @"./../../Components/testresult/CompareTablesFromDifferentPresentations/result.pptx";
            ComparisonPresentationBase result = compareResult.GetPresentation();
            Stream resultStream = new FileStream(resultPath, FileMode.Create);

            result.Save(resultStream, ComparisonSaveFormat.Pptx);
            resultStream.Close();
            Console.WriteLine("Result of comparison was saved to presentation with the folloving source path" +
                              resultPath + ".");
            Console.WriteLine("===============================================");
            Console.WriteLine("");
        }
        public static void CompareParagraphFromPresentationsWithCreatingParagraph()
        {
            string sourcePath =
                @"GroupDocs.Comparison.Samples.Slides.Components.data.CompareParagraphFromPresentationsWithCreatingParagraph.old.pptx";

            // Create to stream of presentation
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   sourceStream = assembly.GetManifestResourceStream(sourcePath);

            // Opening source presentation
            ComparisonPresentationBase sourcePresentation = new ComparisonPresentation(sourceStream);

            Console.WriteLine("Presentation with source path: " + sourcePath + " was loaded.");

            // Getting first Paragraph from source presentation
            ComparisonParagraphBase sourceParagraph =
                (sourcePresentation.Slides[0].Shapes[0] as ComparisonAutoShapeBase).TextFrame.Paragraphs[0];
            // Creating Paragraph
            ComparisonParagraphBase targetParagraph = new ComparisonParagraph();

            targetParagraph.Text = "This Paragraph was created.";
            Console.WriteLine("New Paragraph was created.");

            // Creating settings for comparison of Paragraphs
            SlidesComparisonSettings SlidesComparisonSettings = new SlidesComparisonSettings();
            // Comparing Paragraphs
            ISlidesCompareResult compareResult = sourceParagraph.CompareWith(targetParagraph, SlidesComparisonSettings);

            Console.WriteLine("Paragraphs was compared.");

            // Saving result of comparison to new presentation
            string resultPath =
                @"./../../Components/testresult/CompareParagraphFromPresentationsWithCreatingParagraph/result.pptx";
            ComparisonPresentationBase result = compareResult.GetPresentation();
            Stream resultStream = new FileStream(resultPath, FileMode.Create);

            result.Save(resultStream, ComparisonSaveFormat.Pptx);
            resultStream.Close();
            Console.WriteLine("Result of comparison was saved to presentation with the folloving source path" +
                              resultPath + ".");
            Console.WriteLine("===============================================");
            Console.WriteLine("");
        }
        public static void CompareColumnFromPresentationsWithCreatingColumn()
        {
            string sourcePath =
                @"GroupDocs.Comparison.Samples.Slides.Components.data.CompareColumnFromPresentationsWithCreatingColumn.old.pptx";

            // Create to stream of presentation
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   sourceStream = assembly.GetManifestResourceStream(sourcePath);

            // Opening source presentation
            ComparisonPresentationBase sourcePresentation = new ComparisonPresentation(sourceStream);

            Console.WriteLine("Presentation with source path: " + sourcePath + " was loaded.");

            // Getting first Column from source presentation
            ComparisonColumnBase sourceColumn = (sourcePresentation.Slides[0].Shapes[0] as ComparisonTableBase).Columns[0];
            // Creating Column
            ComparisonColumnBase targetColumn = new ComparisonColumn(new double[] { 50, 50 }, 200);

            targetColumn[0].TextFrame.Paragraphs[0].Text = "This is first cell in Column that was created.";
            targetColumn[1].TextFrame.Paragraphs[0].Text = "This is second cell in Column that was created.";
            Console.WriteLine("New Column was created.");

            // Creating settings for comparison of Columns
            SlidesComparisonSettings SlidesComparisonSettings = new SlidesComparisonSettings();
            // Comparing Columns
            ISlidesCompareResult compareResult = sourceColumn.CompareWith(targetColumn, SlidesComparisonSettings);

            Console.WriteLine("Columns was compared.");

            // Saving result of comparison to new presentation
            string resultPath = @"./../../Components/testresult/CompareColumnFromPresentationsWithCreatingColumn/result.pptx";
            ComparisonPresentationBase result = compareResult.GetPresentation();
            Stream resultStream = new FileStream(resultPath, FileMode.Create);

            result.Save(resultStream, ComparisonSaveFormat.Pptx);
            resultStream.Close();
            Console.WriteLine("Result of comparison was saved to presentation with the folloving source path" +
                              resultPath + ".");
            Console.WriteLine("===============================================");
            Console.WriteLine("");
        }