public ToxySlideshow Parse()
        {
            if (!File.Exists(Context.Path))
                throw new FileNotFoundException("File " + Context.Path + " is not found");

            ToxySlideshow ss = new ToxySlideshow();

            using (PresentationDocument ppt = PresentationDocument.Open(Context.Path, false))
            {
                // Get the relationship ID of the first slide.
                PresentationPart part = ppt.PresentationPart;
                DocumentFormat.OpenXml.OpenXmlElementList slideIds = part.Presentation.SlideIdList.ChildElements;
                for (int index = 0; index < slideIds.Count; index++)
                {
                    string relId = (slideIds[index] as SlideId).RelationshipId;
                    relId = (slideIds[index] as SlideId).RelationshipId;

                    // Get the slide part from the relationship ID.
                    SlidePart slide = (SlidePart)part.GetPartById(relId);
                    var tslide= Parse(slide);
                    ss.Slides.Add(tslide);
                }
            }
            return ss;
        }
        public ToxySlideshow Parse()
        {
            if (!File.Exists(Context.Path))
            {
                throw new FileNotFoundException("File " + Context.Path + " is not found");
            }

            ToxySlideshow ss = new ToxySlideshow();

            using (PresentationDocument ppt = PresentationDocument.Open(Context.Path, false))
            {
                // Get the relationship ID of the first slide.
                PresentationPart part = ppt.PresentationPart;
                DocumentFormat.OpenXml.OpenXmlElementList slideIds = part.Presentation.SlideIdList.ChildElements;
                for (int index = 0; index < slideIds.Count; index++)
                {
                    string relId = (slideIds[index] as SlideId).RelationshipId;
                    relId = (slideIds[index] as SlideId).RelationshipId;

                    // Get the slide part from the relationship ID.
                    SlidePart slide  = (SlidePart)part.GetPartById(relId);
                    var       tslide = Parse(slide);
                    ss.Slides.Add(tslide);
                }
            }
            return(ss);
        }
Example #3
0
        public string ExtractText(string filePath, string extension)
        {
            StringBuilder textResult = new StringBuilder("");

            ParserContext    context   = new ParserContext(filePath);
            ISlideshowParser parser    = ParserFactory.CreateSlideshow(context);
            ToxySlideshow    slideshow = parser.Parse();

            foreach (ToxySlide slide in slideshow.Slides)
            {
                foreach (String text in slide.Texts)
                {
                    textResult.Append('.' + text);
                }
            }

            return(textResult.ToString());
        }