スライド要素チュートリアル
IronPPTは、.NET C#開発者がアプリケーションにPowerPointプレゼンテーションの作成、読み取り、および編集機能をシームレスに統合するのを支援するために設計された強力なPowerPointライブラリです。 PowerPointプレゼンテーションの文脈では、スライドはコンテンツを構造化し整理する基礎的な要素です。
目次
-
テキストを追加
- テキスト・コンテンツ (追加、挿入、削除)
- スタイリングの設定 (フォントファミリーとサイズ、色、太字と斜体、取り消し線、下線)
-
画像を追加
- 位置を設定する
-
図形を追加
テキストを追加
テキストコンテンツ
新しいプレゼンテーションを作成する場合でも、既存のものを編集する場合でも、テキストの管理ツールを使用すると、テキストの配置や書式設定を完全に制御でき、メッセージを明確かつプロフェッショナルに伝えるスライドをデザインできます。
: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")