IRONSOFTWAREHOME

C# Slide Element Tutorial – IronPPT

Curtis Chau
Curtis Chau
Updated: 2026年6月29日

IronPPT は、.NET C# 開発者が PowerPoint プレゼンテーションの作成、読み取り、編集機能をアプリケーションにシームレスに統合できるように設計された強力な PowerPoint ライブラリです。 PowerPoint プレゼンテーションのコンテキストでは、スライドはコンテンツを構造化して整理する基本要素です。

Quickstart: 新しいスライドまたは既存のスライドにテキストを挿入

この例では、IronPPT を使用してスライドにテキストを簡単に追加できる方法を示します。 わずか数行で、最初のスライドがある場合はそこに挿入するか、新しいスライドを作成して保存します。セットアップが速く、手間が最小限です。

  1. 1Install IronPPT with NuGet Package Manager

    PM > Install-Package IronPPT

  2. 2このコード スニペットをコピーして実行します。

    var doc = new IronPPT.PresentationDocument();
    var text = doc.Slides.Count > 0 ? doc.Slides[0].AddText("Quick Option") : doc.Slides.Add(new IronPPT.Models.Slide()).AddText("Quick Option");
    doc.Save("quick.pptx");
    C#
  3. 3実際の環境でテストするためにデプロイする

    今日プロジェクトで IronPPT を使い始めましょう無料トライアル
    arrow pointer

目次

テキストを追加

テキストコンテンツ

新しいプレゼンテーションを作成する場合でも、既存のプレゼンテーションを編集する場合でも、テキスト管理ツールを使用すると、テキストの配置と書式設定を完全に制御できるため、メッセージを明確かつプロフェッショナルに伝えるスライドをデザインできます。

using IronPPT;
using IronPPT.Models;

// Create a new PowerPoint presentation
var document = new PresentationDocument();

// Ensure there is at least one slide to work with
if (document.Slides.Count == 0)
{
    document.Slides.Add(new Slide());
}

// Add text to the first slide
var text = document.Slides[0].AddText("Hello");

// Append text to the existing text on the slide
text.Text += " There!";

// Check if there is any text element to remove from the first slide
if (document.Slides[0].Texts.Count > 0)
{
    document.Slides[0].Texts[0].Remove();
}

// Export the PowerPoint presentation with the specified file name
document.Save("addText.pptx");
C#

スタイリング設定

テキストのスタイル設定では、フォントサイズ、色、スタイル、取り消し線、下線などの属性を定義して、テキストの外観をカスタマイズできます。これらのスタイルを適用することで、テキストの見栄えが向上し、ドキュメント全体の見栄えが向上します。

using IronPPT;
using IronPPT.Models; // Ensure the library is available
using IronPPT.Enums;

// Create a new presentation document
var document = new PresentationDocument();

// Define and customize the text style
var textStyle = new TextStyle
{
    IsBold = true,                      // Text is bold
    IsItalic = true,                    // Text is italic
    Color = Color.Blue,                 // Text color is blue
    Strike = StrikValue.SingleStrike,   // Text is single struck-off
    Outline = true,                     // Text has an outline
    NoProof = true,                     // Disables proofing for the text
    Spacing = 10.0,                     // Text spacing is set to 10
    Underline = new Underline 
    {
        LineValue = UnderlineValues.Single,   // Single underline
        Color = Color.Red                     // Underline color is red
    },
    Languages = "en-US",               // Text language is set to U.S. English
    SpecVanish = false,                // Text does not vanish when special formatting is applied
};

// Create text content and apply the defined style
var text = new Text("Hello World");   // Instantiate text with a string
text.TextStyle = textStyle;           // Apply the defined style to the text

// Add a new slide if none exist
if (document.Slides.Count == 0)
{
    document.Slides.Add(new Slide());   // Add a new slide to the document
}

// Add the styled text to the first slide
document.Slides[0].AddText(text);      // Add the newly created text object to the first slide

// Save the presentation document to a file
document.Save("textStyle.pptx");        // Save the document with the filename "textStyle.pptx"
C#

画像を追加

最適な表示のために画像設定を調整します。 適切に構成することで、画像が視覚的に魅力的になり、コンテキストに適合したものになります。

using IronPPT;
using IronPPT.Models;
using System.Drawing;

// This script demonstrates the creation of a PowerPoint presentation using the IronPPT library.
// An image is added to the presentation, its properties are modified, and then the presentation is saved.

// Create a new PowerPoint presentation
var document = new PresentationDocument();

// Create a new Image object and load an image file.
var image = new Image();
image.LoadFromFile("sample.png");

// Add the image to the first slide (index 0) of the presentation.
var newImage = document.AddImage(image, 0);

// Set the properties of the added image.
// Position property is set using a Point object, which holds X and Y coordinates.
newImage.Position = new Point(200, 200); // Set image position on the slide
newImage.Angle = 45; // Set the rotation angle of the image
newImage.Name = "new image"; // Assign a descriptive name to the image
newImage.Width = 150; // Set the width of the image in pixels
newImage.Height = 150; // Set the height of the image in pixels

// Export the PowerPoint presentation to a file named "addImage.pptx"
document.Save("addImage.pptx");

図形を追加する

図形の種類、寸法 (幅と高さ)、塗りつぶしとアウトラインの色、スライド上の位置を定義して、プレゼンテーションに図形を簡単に追加およびカスタマイズできます。

using IronPPT;
using IronPPT.Models;
using IronPPT.Enums;

// Load a PowerPoint presentation.
// The PresentationDocument is assumed to represent an entire PPTX file loaded from disk.
var document = new PresentationDocument("output.pptx");

// Configure a new shape.
// Shape is assumed to be a model object representing drawable elements on a slide.
Shape shape = new Shape
{
    Name = "triangle",
    Type = ShapeType.Triangle,
    Width = 100,
    Height = 100,
    FillColor = new Color("#444444"),
    OutlineColor = Color.Black,

    // Position is set via the Position property, which accepts an (x, y) tuple.
    // It's important that these coordinates are valid for display on the slide.
    Position = (200, 200)
};

// Add the shape to the first slide in the presentation.
// Slides[0] refers to the first slide in the collection. Ensure a slide exists at this index.
document.Slides[0].AddShape(shape);

// Export the modified PowerPoint presentation.
// Saves the changes to a new file, ensuring the original presentation is not overwritten.
document.Save("addShape.pptx");
C#

よくある質問

IronPPTの用途

IronPPTは.NET C#開発者向けの包括的なPowerPointライブラリであり、アプリケーション内でPowerPointプレゼンテーションをシームレスに作成、読み取り、編集できるようにします。

IronPPTを使用してスライドにテキストを追加する方法

IronPPTを使用してスライドにテキストを追加するには、数行のコードで既存のスライドにテキストを挿入したり、新しいスライドを作成したりし、その後プレゼンテーションを保存します。

IronPPTでテキストスタイリングをカスタマイズできますか?

はい、IronPPTではフォントサイズ、色、スタイル、取り消し線、下線などの属性を定義することでテキストのスタイリングをカスタマイズできます。

IronPPTでPowerPointプレゼンテーションに画像を追加する方法

IronPPTは、ファイルまたはFileStreamsから画像を読み込み、プレゼンテーションでの最適な表示を確保するためにその寸法、角度、および位置を構成するツールを提供します。

IronPPTでシェイプを追加できますか?

はい、IronPPTではそのタイプ、寸法、塗りつぶしとアウトラインの色、およびスライド上の位置を定義することでシェイプを追加およびカスタマイズできます。

IronPPTは既存のPowerPointプレゼンテーションの編集をサポートしていますか?

IronPPTは新しいプレゼンテーションの作成と既存のものの編集の両方を可能にし、コンテンツと書式設定を完全に制御できます。

IronPPTではテキストと画像の位置を設定できますか?

はい、IronPPTはスライド上のテキストと画像の位置を設定することを可能にし、プレゼンテーションのレイアウトに合わせた正確な配置を可能にします。

IronPPTで画像挿入をサポートするファイル形式は何ですか?

IronPPTは、さまざまなファイル形式から画像を挿入することをサポートし、プレゼンテーションのビジュアル資産との互換性を保証します。

IronPPTがプレゼンテーションのビジュアルな魅力をどのように強化しますか?

IronPPTは、プロフェッショナルなプレゼンテーションの外観を保証するために、テキストスタイルのカスタマイズ、画像構成、シェイプデザインのツールを提供することで視覚的魅力を強化します。

IronPPTは異なるバージョンのPowerPointと互換性がありますか?

IronPPTは、さまざまなバージョンのPowerPointと互換性を持つように設計されており、C#アプリケーションにシームレスに統合されます。

Curtis Chau
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

...
詳しく読む

準備はできましたか?

Nuget Downloads 6,070バージョン:2026.9リリースされたばかり

PDF用C# NuGetライブラリ
NuGetでインストール

バージョン: 2026.9

PM > Install-Package IronPPT
nuget.org/packages/IronPPT/
  1. ソリューションエクスプローラーで参照を右クリックし、NuGetパッケージを管理を選択
  2. 「参照」を選択して「IronPPT」を検索します
  3. パッケージを選択してインストール
C# PDF DLL
DLLをダウンロード

バージョン: 2026.9

  1. IronPPTをダウンロードして、ソリューションディレクトリ内の~/Libsなどの場所に解凍します
  2. Visual Studioソリューションエクスプローラーで、参照を右クリックします。「IronPPT.dll」を参照して選択します

ライセンスは$999から

Key in blue circle

無料の30日間トライアルキーをすぐに入手してください。

Your trial license will be sent to your email address

制限なし。100% ロック解除済み。クレジットカード不要。

bullet_checkedクレジットカードやアカウントの作成は不要です。制限なし。100% ロック解除済み。クレジットカード不要。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
無料のライブデモを予約する
Booking Badge

世界中の数百万人のエンジニアから信頼されています。

ライセンスはより安く
義務のない相談を受ける
下記のフォームを記入するか、sales@ironsoftware.comにメールしてください。
あなたの詳細は常に守秘されます。
世界中の数百万人のエンジニアから信頼されています。
ライセンスはより安く
あなたの無料30日間の試用キーをすぐに入手。
クレジットカードやアカウントの作成は不要です。