Quantcast
Channel: Open XML Format SDK forum
Viewing all articles
Browse latest Browse all 1288

How to convert Powerpoint .pptx to PDF document?

$
0
0

Hi,

I am using Office Interop to convert powerpoint to pdf using save as functionality with below code. I have some issues with InterOp on some pcs where I get application is busy error.

Is it possible to convert .pptx to .pdf using open xml sdk? if yese, please provide me some sample.

      public static void ConvertPPTtoPDF(string pptFile, string pdfFile)
        {

            try
            {
                Microsoft.Office.Interop.PowerPoint.Application ppApp = new
                    Microsoft.Office.Interop.PowerPoint.Application();

                Microsoft.Office.Interop.PowerPoint.Presentation presentation = ppApp.Presentations.Open
                    (pptFile, Microsoft.Office.Core.MsoTriState.msoTrue,
                        Microsoft.Office.Core.MsoTriState.msoFalse,
                        Microsoft.Office.Core.MsoTriState.msoFalse);
                presentation.ExportAsFixedFormat(pdfFile,

                                PPT.PpFixedFormatType.ppFixedFormatTypePDF,

                                PPT.PpFixedFormatIntent.ppFixedFormatIntentPrint,

                                Microsoft.Office.Core.MsoTriState.msoFalse,

                                PPT.PpPrintHandoutOrder.ppPrintHandoutHorizontalFirst,

                                PPT.PpPrintOutputType.ppPrintOutputSlides,

                                Microsoft.Office.Core.MsoTriState.msoFalse,

                                null,

                                PPT.PpPrintRangeType.ppPrintAll,

                                "",

                                false,

                                false,

                                false,

                                true,

                                true,

                                System.Reflection.Missing.Value);

                presentation.Close();

                presentation = null;

                ppApp = null;

                GC.Collect();
            }
            catch (Exception ex)
            {
                Console.WriteLine("exception happened while converting to PDF file..." + ex);

                throw ex;
            }

        }


VM7258


Viewing all articles
Browse latest Browse all 1288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>