Example #1
0
        static void RunOneFile(string sourceFile, string outputDir)
        {
            Package original = Package.Open(sourceFile, FileMode.Open);

            SlideFromPresentation single = new SlideFromPresentation(original);

            foreach (int slideId in single.SlideRelIds.Keys)
            {
                single.OutputSlide(slideId, outputDir);
            }
        }
Example #2
0
        static void RunOnDirectory(string sourceDir, string outputDir)
        {
            string       directory     = sourceDir;
            var          pptxFiles     = Directory.EnumerateFiles(directory, "*.pptx", SearchOption.AllDirectories);
            StreamWriter catalogWriter = File.CreateText(outputDir + "Catalog.txt");

            Parallel.ForEach(pptxFiles, (currentFile) =>
            {
                Package original = null;
                bool fOkay       = false;
                try
                {
                    original = Package.Open(currentFile, FileMode.Open);
                    fOkay    = true;
                }
                catch (System.IO.FileFormatException)
                {
                    Console.WriteLine("Cannot open " + currentFile);
                }
                catch (System.UnauthorizedAccessException)
                {
                    Console.WriteLine("Cannot access " + currentFile);
                }
                if (fOkay)
                {
                    Console.WriteLine(currentFile);
                    string fileName              = currentFile.Substring(directory.Length + 1);
                    string[] segments            = fileName.Split('\\');
                    string layout                = segments[0];
                    string type                  = segments[1];
                    string crop                  = segments[2];
                    string aspect                = segments[3];
                    string path                  = segments[4];
                    SlideFromPresentation single = new SlideFromPresentation(original);
                    string catalogLines          = string.Empty;
                    foreach (int slideId in single.SlideRelIds.Keys)
                    {
                        single.OutputSlide(slideId, outputDir);
                        catalogLines += single.CurrentBP.Guid + " " + fileName + catalogWriter.NewLine;
                    }
                    catalogWriter.WriteLine(catalogLines);
                }
            }
                             );
            catalogWriter.Flush();
        }