none
PPT & PDF To XPS or PNG RRS feed

  • Question

  • Hi.

    Please Help Me For Convert PPT File To Xps File .

    1 Way : Useing COM . Microsoft.Office.Core , Microsoft.Office.Interop.PowerPoint , ... .

            Microsoft.Office.Interop.PowerPoint.Application powerpoint;
            Microsoft.Office.Interop.PowerPoint.Presentation presentation;
            Microsoft.Office.Interop.PowerPoint.Presentations presentations;
    
            powerpoint = new Microsoft.Office.Interop.PowerPoint.Application();
            presentations = powerpoint.Presentations;
            presentation = presentations.Open(@"d:\test.ppt", MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
            Microsoft.Office.Interop.PowerPoint.Slides slides = presentation.Slides;
            for (int i = 1; i <= slides.Count; i++)
            {
                Microsoft.Office.Interop.PowerPoint.Slide slide = slides[i];
                String slideName = slide.Name;
                releaseCOM(slide);
                slide.Export(@"d:\test\" + i.ToString() + ".xps", "");
            }
    
            private static void releaseCOM(object o)
            {
                try
                {
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(o);
                }
                catch { }
                finally
                {
                    o = null;
                }
            }

    Error in this Way : COM object that has been separated from its underlying RCW cannot be used

    2 Way : Printing File With Microsoft XPS Document Writer  in Window 7.

    ProcessStartInfo psInfo = new ProcessStartInfo();
    
                psInfo.FileName = @"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe";
                string option = @"/t";
                string xps = "Microsoft XPS Document Writer";
                string targetFile = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar +
                    Path.GetFileNameWithoutExtension(filename) +  @".xps";
    
                string Myargs = String.Format("{0} \"{1}\" \"{2}\" {0} \"{3}\"", option, filename, xps, targetFile);
                psInfo.CreateNoWindow = true;
                psInfo.Arguments = Myargs;
                psInfo.UseShellExecute = false;
                psInfo.ErrorDialog = false;
                
                P.StartInfo = psInfo;
                P.Start();
                P.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

    Problem in this Way : CreateNewWindow & No Closeing Window .

    Please HElp Me.Tanks

    • Moved by Paul Zhou Thursday, February 9, 2012 5:47 AM move for better support (From:.NET Base Class Library)
    Tuesday, February 7, 2012 11:36 AM

Answers

All replies