private Microsoft.Office.Server.PowerPoint.Conversion.FixedFormatSettings FillPowerPointConversionOptions(OASModels.ConversionOptions co)
        {
            Microsoft.Office.Server.PowerPoint.Conversion.FixedFormatSettings res = new Microsoft.Office.Server.PowerPoint.Conversion.FixedFormatSettings();


            res.BitmapUnembeddableFonts      = co.BitmapEmbeddedFonts;
            res.FrameSlides                  = co.FrameSlides;
            res.IncludeDocumentProperties    = co.IncludeDocumentProperties;
            res.IncludeDocumentStructureTags = co.IncludeDocumentStructure;
            res.IncludeHiddenSlides          = co.IncludeHiddenSlides;
            res.OptimizeForMinimumSize       = (co.OutputQuality == OASModels.FixedFormatQuality.Minimum ? true : false);
            res.UsePdfA          = co.UsePDFA;
            res.UseVerticalOrder = co.UseVerticalOrder;

            return(res);
        }
        private OASResponse StartPPTConversion(OASModels.ConversionSettings settings, SPUserToken userToken)
        {
            OASResponse oasResponse = new OASResponse();

            using (SPSite site = (userToken == null ? new SPSite(ConfigurationManager.AppSettings["SiteUrl"]) : new SPSite(ConfigurationManager.AppSettings["SiteUrl"], userToken)))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    try
                    {
                        web.AllowUnsafeUpdates = true;

                        byte[] input = Convert.FromBase64String(settings.Content);

                        SPFolder lib = GetOASLibrary(web);

                        //add source file to library
                        string source  = Guid.NewGuid().ToString();
                        SPFile srcfile = lib.Files.Add(source, input, true);

                        string dest = source + EXTENSION;


                        //Set up the job
                        MemoryStream ms = new MemoryStream();
                        Microsoft.Office.Server.PowerPoint.Conversion.FixedFormatSettings ppsettings = FillPowerPointConversionOptions(settings.Options);

                        PdfRequest request = new PdfRequest(new MemoryStream(input), ".pptx", ppsettings, ms);

                        PPTJob job = new PPTJob();
                        job.source  = source;
                        job.dest    = dest;
                        job.web     = web;
                        job.output  = ms;
                        job.request = request;

                        IAsyncResult result = request.BeginConvert(SPServiceContext.GetContext(web.Site), PPTConversionFinished, job);

                        // put file to the processing list
                        AddFileToList(web, job.jobId.ToString(), dest, DocType.PPTX);

                        oasResponse.FileId    = job.jobId.ToString();
                        oasResponse.ErrorCode = OASErrorCodes.Success;
                    }
                    catch (Exception ex)
                    {
                        oasResponse.ErrorCode = OASErrorCodes.ErrFailedConvert;
                        oasResponse.Message   = ex.Message;
                    }
                }
            }

            return(oasResponse);
        }
        private OASResponse ConvertPPTImmediately(OASModels.ConversionSettings settings, SPUserToken userToken)
        {
            OASResponse oasResponse = new OASResponse();

            using (SPSite site = (userToken == null ? new SPSite(ConfigurationManager.AppSettings["SiteUrl"]) : new SPSite(ConfigurationManager.AppSettings["SiteUrl"], userToken)))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    byte[]       input     = Convert.FromBase64String(settings.Content);
                    MemoryStream outstream = new MemoryStream();

                    try
                    {
                        Microsoft.Office.Server.PowerPoint.Conversion.FixedFormatSettings ppsettings = FillPowerPointConversionOptions(settings.Options);

                        PdfRequest request = new PdfRequest(new MemoryStream(input), ".pptx", ppsettings, outstream);

                        IAsyncResult result = request.BeginConvert(SPServiceContext.GetContext(site), null, null);

                        // Use the EndConvert method to get the result.
                        request.EndConvert(result);

                        oasResponse.Content   = Convert.ToBase64String(outstream.ToArray());
                        oasResponse.ErrorCode = OASErrorCodes.Success;
                    }
                    catch (Exception ex)
                    {
                        oasResponse.ErrorCode = OASErrorCodes.ErrFailedConvert;
                        oasResponse.Message   = ex.Message;
                    }
                }
            }

            return(oasResponse);
        }