翻譯|使用教程|編輯:吉煒煒|2025-01-14 14:27:22.230|閱讀 94 次
概述:為方便使用者快速掌握和了解Spire.Presentation,本文列舉了PPT處理控件Spire.Presentation常見問題及解答,歡迎下載最新版體驗!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
為方便使用者快速掌握和了解Spire.Presentation,本文列舉了PPT處理控件Spire.Presentation常見問題及解答,歡迎下載最新版體驗!
如何給PowerPoint文檔添加密碼保護?
請使用Encrypt方法給文檔加密。全部代碼:
Presentation presentation = new Presentation(); presentation.LoadFromFile("sample.pptx"); presentation.Encrypt("test"); presentation.SaveToFile("encrypt.pptx", FileFormat.Pptx2010);
如何轉換PowerPoint文件到PDF?
只需要加載文件,然后保存成PDF即可。全部代碼:
Presentation presentation = new Presentation(); //加載文件 presentation.LoadFromFile("ppt.ppt"); //把文件保存成PDF presentation.SaveToFile("ToPdf.pdf", FileFormat.PDF);
如何將幻燈片保存成圖片?
請使用SaveAsImage方法將幻燈片保存到Image中,然后將Image對象保存成圖片。全部代碼:
Presentation ppt = new Presentation(); ppt.LoadFromFile(@"F:\testing\Sample.pptx"); for (int i = 0; i < ppt.Slides.Count; i++) { //將幻燈片保存到Image中 Image image = ppt.Slides[i].SaveAsImage(); String fileName = String.Format("5614-img-{0}.png", i); //將image保存成文件 image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png); }
如何設置文本框中文本的對齊方式?
請使用Alignment設置文本的對齊方式。全部代碼:
Presentation presentation = new Presentation(); //添加一個shape IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 600, 400)); //設置shape里面第一段的對齊方式為左對齊 shape.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Left; shape.Fill.FillType = FillFormatType.None; //添加文本 shape.TextFrame.Text = "Demo about Alignment"; presentation.SaveToFile("alignment.pptx", FileFormat.Pptx2010);
如何提取PowerPoint中的文本?
請您使用TextParagraph的Text屬性。全部代碼:
StringBuilder sb = new StringBuilder(); for (int i = 0; i < ppt.Slides.Count;i++ ) { for (int j = 0; j < ppt.Slides[i].Shapes.Count;j++ ) { if (ppt.Slides[i].Shapes[j] is IAutoShape) { IAutoShape shape=ppt.Slides[i].Shapes[j] as IAutoShape; if (shape.TextFrame != null) { foreach (TextParagraph tp in shape.TextFrame.Paragraphs) { sb.Append(tp.Text + Environment.NewLine); } } } } }
如何用圖片填充形狀?
請使用PictureShape的Url屬性。全部代碼:
Presentation ppt = new Presentation(); IAutoShape shape = (IAutoShape)ppt.Slides[0].Shapes.AppendShape(ShapeType.DoubleWave, new RectangleF(100, 100, 400, 200)); string picUrl = @"C:\Users\Administrator\Desktop\image.jpg"; shape.Fill.FillType = FillFormatType.Picture; shape.Fill.PictureFill.Picture.Url = picUrl; shape.Fill.PictureFill.FillType = PictureFillType.Stretch; shape.ShapeStyle.LineColor.Color = Color.Transparent; ppt.SaveToFile("shape.pptx", FileFormat.Pptx2010);
歡迎下載|體驗更多E-iceblue產品
獲取更多信息請咨詢 ;技術交流Q群(767755948)
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn