Beispiel #1
0
        public static void PPTToHtml(string path)
        {
            Microsoft.Office.Interop.PowerPoint.Application ppApp = new Microsoft.Office.Interop.PowerPoint.Application();
            string strSourceFile      = path;
            string strDestinationFile = path.Substring(0, path.Length - 3) + ".html";

            Microsoft.Office.Interop.PowerPoint.Presentation prsPres = ppApp.Presentations.Open(strSourceFile, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
            prsPres.SaveAs(strDestinationFile, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsHTML, MsoTriState.msoTrue);
            prsPres.Close();
            ppApp.Quit();
        }
Beispiel #2
0
        public void Add2Index()
        {
            Microsoft.Office.Interop.PowerPoint.Presentation pp = null;

            StringBuilder sb = new StringBuilder();

            sb.Append(string.Empty);
            string err = string.Empty;

            try
            {
                pp = PptApp.Presentations.Open(fileMeta.FileName, OfficeCore.MsoTriState.msoTrue, OfficeCore.MsoTriState.msoFalse, OfficeCore.MsoTriState.msoFalse);
                foreach (Microsoft.Office.Interop.PowerPoint.Slide slide in pp.Slides)
                {
                    foreach (Microsoft.Office.Interop.PowerPoint.Shape shape in slide.Shapes)
                    {
                        if (shape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            var textFrame = shape.TextFrame;
                            if (textFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
                            {
                                var    textRange = textFrame.TextRange;
                                string item      = Convert.ToString(textRange.Text);
                                sb.Append(item);
                                sb.Append(Environment.NewLine);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lock (oLockSbErr)
                {
                    sbErr.Append(ex.Message);
                    sbErr.Append(" ");
                    sbErr.Append(fileMeta.FileName);
                    sbErr.Append(Environment.NewLine);
                }
            }
            finally
            {
                if (pp != null)
                {
                    pp.Close();
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pp);
                    pp = null;
                }
            }
            luceneIndex.BuildIndex(sb.ToString(), fileMeta.FileName, fileMeta.LastWriteTime);
        }
Beispiel #3
0
        public string[] GetText(string sFileName)
        {
            StringBuilder sb  = new StringBuilder();
            string        err = string.Empty;

            try
            {
                if (pptApp == null)
                {
                    pptApp = new PowerPoint.Application();
                }
                pp = pptApp.Presentations.Open(sFileName, OfficeCore.MsoTriState.msoTrue, OfficeCore.MsoTriState.msoFalse, OfficeCore.MsoTriState.msoFalse);
                foreach (Microsoft.Office.Interop.PowerPoint.Slide slide in pp.Slides)
                {
                    foreach (Microsoft.Office.Interop.PowerPoint.Shape shape in slide.Shapes)
                    {
                        if (shape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            var textFrame = shape.TextFrame;
                            if (textFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
                            {
                                var    textRange = textFrame.TextRange;
                                string item      = Convert.ToString(textRange.Text);
                                sb.Append(item);
                                sb.Append(Environment.NewLine);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                sb.Append(sFileName);
                err = sFileName + " - " + ex.Message;
            }
            finally
            {
                if (pp != null)
                {
                    pp.Close();
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pp);
                    pp = null;
                }
            }
            return(new string[] { sb.ToString(), err });
        }