幻燈片元素教程
IronPPT 是一個強大的 PowerPoint 函式庫,旨在幫助 .NET C# 開發人員將創建、读取和编辑 PowerPoint 演示文稿的功能无缝集成到其应用程序中。 在 PowerPoint 簡報中,幻燈片是構建和組織內容的基礎元素。
目錄
- 新增文字
- 文字內容 (添加、追加和移除)
- 設置樣式 (字體家族與大小、顏色、粗體與斜體、刪除線、底線)
- 添加圖片
- 載入圖片 (檔案與檔案流)
- 設定尺寸和角度 (寬度和高度)
- 設定位置
- 添加形狀
- Set shape type
- 設置尺寸 (寬度和高度)
- 設定填充和輪廓顏色
- 設定位置
開始使用IronPPT
立即在您的專案中使用IronPPT,並享受免費試用。
新增文字
文字內容
無論您是創建新簡報還是編輯現有的簡報,文本管理工具都能讓您完全控制文本的放置和格式,幫助您設計出清晰且專業地傳達訊息的幻燈片。
:path=/static-assets/ppt/content-code-examples/tutorials/slide-element-add-text.cs
using IronPPT;
using IronPPT.Models;
// Create new PowerPoint presentation
var document = new PresentationDocument();
// Add text
var text = document.Slides[0].AddText("Hello");
// Append text
text.Append(new Text(" There!"));
// Remove text
document.Slides[0].Texts[0].Remove();
// Export PowerPoint presentation
document.Save("addText.pptx");
Imports IronPPT
Imports IronPPT.Models
' Create new PowerPoint presentation
Private document = New PresentationDocument()
' Add text
Private text = document.Slides(0).AddText("Hello")
' Append text
text.Append(New Text(" There!"))
' Remove text
document.Slides(0).Texts(0).Remove()
' Export PowerPoint presentation
document.Save("addText.pptx")
設置樣式
樣式化文本允許您通過定義屬性如字型大小、顏色、樣式、刪除線和底線來自訂其視覺外觀。應用這些樣式可以增強文本的呈現效果並改善文檔的整體外觀。
:path=/static-assets/ppt/content-code-examples/tutorials/slide-element-text-style.cs
using IronPPT;
using IronPPT.Models;
var document = new PresentationDocument();
// Customize text style
var textStyle = new TextStyle
{
IsBold = true,
IsItalic = true,
Color = Color.Blue,
Strike = StrikValue.SingleStrike,
Outline = true,
NoProof = true,
Spacing = 10.0,
Underline = new Underline { LineValue = UnderlineValues.Single, Color = Color.Red },
Languages = "en-US",
SpecVanish = false,
};
// Add style to text
var text = new Text("Hello World");
text.TextStyle = textStyle;
// Add text
document.Slides[0].AddText(text);
document.Save("textStyle.pptx");
Imports IronPPT
Imports IronPPT.Models
Private document = New PresentationDocument()
' Customize text style
Private textStyle = New TextStyle With {
.IsBold = True,
.IsItalic = True,
.Color = Color.Blue,
.Strike = StrikValue.SingleStrike,
.Outline = True,
.NoProof = True,
.Spacing = 10.0,
.Underline = New Underline With {
.LineValue = UnderlineValues.Single,
.Color = Color.Red
},
.Languages = "en-US",
.SpecVanish = False
}
' Add style to text
Private text = New Text("Hello World")
text.TextStyle = textStyle
' Add text
document.Slides(0).AddText(text)
document.Save("textStyle.pptx")
添加圖片
調整圖像設定以達到最佳顯示效果。 適當的配置可確保影像視覺上吸引人,並適合其上下文。
:path=/static-assets/ppt/content-code-examples/tutorials/slide-element-add-image.cs
using IronPPT;
using IronPPT.Models;
// Create new PowerPoint presentation
var document = new PresentationDocument();
// Add image
Image image = new Image();
image.LoadFromFile("sample.png");
var newImage = document.AddImage(image, 0);
// Edit image's properties
newImage.Position = (200, 200);
newImage.Angle = 45;
newImage.Name = "new image";
newImage.Width = 150;
newImage.Height = 150;
// Export PowerPoint presentation
document.Save("addImage.pptx");
Imports IronPPT
Imports IronPPT.Models
' Create new PowerPoint presentation
Private document = New PresentationDocument()
' Add image
Private image As New Image()
image.LoadFromFile("sample.png")
Dim newImage = document.AddImage(image, 0)
' Edit image's properties
newImage.Position = (200, 200)
newImage.Angle = 45
newImage.Name = "new image"
newImage.Width = 150
newImage.Height = 150
' Export PowerPoint presentation
document.Save("addImage.pptx")
添加形狀
輕鬆地在您的演示文稿中添加和自訂形狀,通過定義它們的類型和尺寸(寬度和高度)、填充和輪廓顏色,以及在幻燈片上的位置。
:path=/static-assets/ppt/content-code-examples/tutorials/slide-element-add-image.cs
using IronPPT;
using IronPPT.Models;
// Create new PowerPoint presentation
var document = new PresentationDocument();
// Add image
Image image = new Image();
image.LoadFromFile("sample.png");
var newImage = document.AddImage(image, 0);
// Edit image's properties
newImage.Position = (200, 200);
newImage.Angle = 45;
newImage.Name = "new image";
newImage.Width = 150;
newImage.Height = 150;
// Export PowerPoint presentation
document.Save("addImage.pptx");
Imports IronPPT
Imports IronPPT.Models
' Create new PowerPoint presentation
Private document = New PresentationDocument()
' Add image
Private image As New Image()
image.LoadFromFile("sample.png")
Dim newImage = document.AddImage(image, 0)
' Edit image's properties
newImage.Position = (200, 200)
newImage.Angle = 45
newImage.Name = "new image"
newImage.Width = 150
newImage.Height = 150
' Export PowerPoint presentation
document.Save("addImage.pptx")