ユーザー定義のサイズでスライドからサムネイルを生成する

Aspose.Slides for .NET を使用して任意のスライドのサムネイルを生成するには:

  • Presentation クラスのインスタンスを作成します。
  • スライドの ID またはインデックスを使用して、任意のスライドの参照を取得します。
  • ユーザー定義の X および Y の寸法に基づいて、X と Y のスケーリング係数を取得します。
  • 指定したスケールで参照されたスライドのサムネイル画像を取得します。
  • サムネイル画像を任意の画像形式で保存します。

//Instantiate the Presentation class that represents the presentation file
using (Presentation pres = new Presentation("TestPresentation.pptx"))
{
    //Access the first slide
    ISlide sld = pres.Slides[0];

    //User defined dimension
    int desiredX = 1200;
    int desiredY = 800;

    //Getting scaled value  of X and Y
    float scaleX = (float)(1.0 / pres.SlideSize.Size.Width) * desiredX;
    float scaleY = (float)(1.0 / pres.SlideSize.Size.Height) * desiredY;

    //Create a full scale image
    using (IImage image = sld.GetImage(scaleX, scaleY))
    {
        //Save the image to disk in JPEG format
        image.Save("Thumbnail2.jpg", ImageFormat.Jpeg);
    }
}

実行サンプルのダウンロード

サンプルコードのダウンロード