如何将特定的html部分转换为powerpoint格式,即ppt?

时间:2017-05-15 08:45:02

标签: html reactjs powerpoint

我在当前的React项目中有一个要求,要将当前页面的特定div从客户端转换为.ppt(不是pdf或image)。 反正有没有直接这样做?

1 个答案:

答案 0 :(得分:1)

finalOutputDoc.Save(@" C:\ temp \ temp.html",Aspose.Pdf.SaveFormat.Html);

        //Next convert to powerpoint
        //Create Empty presentation instance//Create Empty presentation instance
        //using (Aspose.Slides.Presentation pres = new Aspose.Slides.Presentation())
        //Create Empty presentation instance//Create Empty presentation instance
        //Create Empty presentation instance//Create Empty presentation instance
        using (Presentation pres = new Presentation())
        {
            //Acesss the default first slide of presentation

            ISlide slide = pres.Slides[0];

            //Adding the AutoShape to accomodate the HTML content
            IAutoShape ashape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, pres.SlideSize.Size.Width - 20, pres.SlideSize.Size.Height - 10);

            ashape.FillFormat.FillType = FillType.NoFill;

            //Adding text frame to the shape
            ashape.AddTextFrame("");

            //Clearing all paragraphs in added text frame
            ashape.TextFrame.Paragraphs.Clear();

            //Loading the HTML file using stream reader
            TextReader tr = new StreamReader(@"C:\temp\temp.html");

            //Adding text from HTML stream reader in text frame
            ashape.TextFrame.Paragraphs.AddFromHtml(tr.ReadToEnd());

            //Saving Presentation
            pres.Save(@"C:\temp\output.pptx", Aspose.Slides.Export.SaveFormat.Pptx);

        }