C#はテキストと画像を含むPowerPointドクムを生成
PowerPointドキュメント(スライド)は、一般的なプレゼンテーションのドキュメントであり、スピーチ、教育、製品のプレゼンテーションなどの面で広く応用されている。この文は、簡単なPowerPointファイルを作成する方法を紹介します。
以下のコードを使用する前に必要:
- ダウンロードFree Spire.Presentation,インストール経路から引用Spire.Presentation.dllアプリケーション.
- 名のスペースを引用する:
using Spire.Presentation;
using Spire.Presentation.Drawing;
簡単なPowerPointドキュメントを作成
// 新しいPowerPointドキュメントを作成します(デフォルトの1ページの空白のスライドを含む) Presentation ppt = new Presentation();
//スライドサイズと方向を設定
ppt.SlideSize.Type = SlideSizeType.Screen16x9;
ppt.SlideSize.Orientation = SlideOrienation.Landscape;
//スライドに背景画像を設定する
string ImageFile = "background.png";
RectangleF rect = new RectangleF(0, 0, ppt.SlideSize.Size.Width, ppt.SlideSize.Size.Height);
ppt.Slides[0].SlideBackground.Fill.FillType = FillFormatType.Picture;
IEmbedImage image = ppt.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
ppt.Slides[0].SlideBackground.Fill.PictureFill.Picture.EmbedImage = image as IImageData;
//第1枚のスライドにパターンを追加
IAutoShape textboxShape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 600, 100));
textboxShape.ShapeStyle.LineColor.Color = Color.Transparent;
textboxShape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;
//図形の段落をクリアする(デフォルトの空白がある)
textboxShape.TextFrame.Paragraphs.Clear();
//図形に段落と内容を追加する
textboxShape.TextFrame.Paragraphs.Append(new TextParagraph());
textboxShape.TextFrame.Paragraphs[0].TextRanges.Append(new TextRange("Spire.Presentation for .NET"));
textboxShape.TextFrame.Paragraphs[0].SpaceAfter = 50f;
//第2段の内容を追加
textboxShape.TextFrame.Paragraphs.Append(new TextParagraph());
string text = "プロフェッショナルのPowerPointコンポーネントは、PowerPointドキュメントの生成、読み取り、書き込み、修正、変換、印刷などの操作を行うことができます。";
textboxShape.TextFrame.Paragraphs[1].TextRanges.Append(new TextRange(text));
//段落中の文字のフォント、サイズ、色、段落の揃え方、段首が距離を縮める
foreach (TextParagraph para in textboxShape.TextFrame.Paragraphs)
{
para.TextRanges[0].LatinFont = new TextFont("Arial Rounded MT Bold");
para.TextRanges[0].FontHeight = 13f;
para.TextRanges[0].Fill.FillType = FillFormatType.Solid;
para.TextRanges[0].Fill.SolidColor.Color = Color.Black;
para.Alignment = TextAlignmentType.Left;
para.Indent = 35;
}
//ファイルを保存する
ppt.SaveToFile("CreatPPT.pptx", FileFormat.Pptx2013);
総括する
ネットでPowerPointの部品を操作するのは多くありません,Free Spire.Presentation優勢は無料で使いやすい,機能がそろっている,ただ、無料版だけで10枚のスライドを処理する制限があります,普通の利用者にとっては十分だ,より大きなスライドドキュメントを操作する必要がある場合,ビジネス版もあります,ページ制限はない。
Author And Source
この問題について(C#はテキストと画像を含むPowerPointドクムを生成), 我々は、より多くの情報をここで見つけました https://qiita.com/iceblue/items/3295c9fb5c359d88ded6著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .