このトピックでは、C#を使用してPowerPointをTIFFに変換する方法と、環境を構成して動作するサンプルコードを確認するための詳細な構成手順に焦点を当てます。このアプリケーションは、Windows、macOS、およびLinuxの.NETでサポートされている環境のいずれかで使用して、 C#でPPTXをTIFFに変換**できます。
C#を使用してPowerPointをTIFFに変換する手順
- NuGetパッケージマネージャーを使用してAspose.Slides for .NETをインストールするようにアプリケーションを構成します
- Presentationクラスオブジェクトを使用してソースプレゼンテーションファイルをロードし、TIFFに変換します
- TiffOptionsクラスオブジェクトを初期化して、目的の画像オプションを設定します
- 目的のTIFF画像のDPIとサイズを設定します
- Saveメソッドを使用してプレゼンテーションをTIFF画像に変換します
前述の手順では、Presentationクラスを使用してソースプレゼンテーションファイルをロードすることでプロセスが開始される場合にのみ、いくつかのAPI呼び出しを使用して**プレゼンテーションをC#**でTIFFに変換します。次に、TiffOptionsクラスインスタンスを使用して、DPIや画像サイズなどの出力TIFF画像オプションを設定してから、Saveメソッドを使用してプレゼンテーションをTIFF画像としてディスクに保存します。
C#でPPTXをTIFFに変換するコード
using System; | |
using System.Drawing; | |
using Aspose.Slides; | |
using Aspose.Slides.Export; | |
namespace TestSlides | |
{ | |
public class PresentationToTiffConverter | |
{ | |
public static void CreateTiffImage() | |
{ | |
// Initialize a license to avoid watermark in the output Tiff Image | |
Aspose.Slides.License licenseSlides = new Aspose.Slides.License(); | |
licenseSlides.SetLicense("Aspose.Total.lic"); | |
// Initliazing the Presentation class to load the source presentation and converting to Tiff | |
using (Presentation SampleTiffPres = new Presentation("NewPresentation.pptx")) | |
{ | |
// Initialize the TiffOptions class | |
TiffOptions tiffOptions = new TiffOptions(); | |
// Setting the Tiff compression type | |
tiffOptions.CompressionType = TiffCompressionTypes.Default; | |
// Customizing the slides notes option inside exported Tiff | |
INotesCommentsLayoutingOptions notesOptions = tiffOptions.NotesCommentsLayouting; | |
notesOptions.NotesPosition = NotesPositions.BottomFull; | |
// Setting the Tiff image DPI. The resolution unit is always equal to 2-dots per inch | |
tiffOptions.DpiX = 200; | |
tiffOptions.DpiY = 100; | |
// Set the desired Tiff output Image Size | |
tiffOptions.ImageSize = new Size(1728, 1078); | |
// Save the source presentation to Tiff with set image size | |
SampleTiffPres.Save("ExpoertedTiff_out.tiff", SaveFormat.Tiff, tiffOptions); | |
} | |
} | |
} | |
} |
上記の例は、同じコードベースを使用して* C#でPPTをTIFFに変換*するためにも使用できます。 TiffOptionsクラスは、CompressionType、PixelFormat、ShowHiddenSlides、NotesCommentsLayoutingの設定などのオプションを公開することにより、出力TIFFをさらにカスタマイズできます。上記のアプリケーションは、MS PowerPointやその他のサードパーティツールをインストールしなくても、PPTXをTIFFにシームレスに変換できます。
このチュートリアルでは、簡単な手順を実行し、簡単なAPIインターフェイスを使用して、* C#でPowerPointからTIFFを生成する*方法を学びました。プレゼンテーションスライド画像の作成に興味がある場合は、C#を使用してPowerPointスライド画像を作成する方法の記事を参照してください。