チュートリアル

簡単にライブラリーを使用するためのチュートリアルコレクション

チュートリアル»pptnetconversion

Displaying items by tag: pptnetconversion

時々、あらかじめ作成された画像ファイルのセットから PowerPoint 文書を作成する必要があります。 たとえば、会社から素敵なチラシが提供され、それらを1つの PowerPoint 文書にまとめて、各画像を整然と表示する必要があります。この記事では、Spire.Presentation for .NET を使用して画像ファイル(PNG、JPG、BMP など)を PowerPoint に変換する方法について説明します。

Spire.Presentation for .NET をインストールします

まず、Spire.Presentation for .NET パッケージに含まれている DLL ファイルを .NET プロジェクトの参照として追加する必要があります。DLL ファイルは、このリンクからダウンロードするか、NuGet を介してインストールできます。

PM> Install-Package Spire.Presentation

画像を PowerPoint の背景に変換する

PowerPoint の各スライドの背景として画像が変換される場合、それらは移動や拡大縮小ができません。以下は、Spire.Presentation for .NET を使用して、画像を PowerPoint ファイルに背景画像として変換する手順です。

  • Presentation オブジェクトを作成します。
  • スライドのサイズの種類を Sreen16x9 に設定します。
  • フォルダーから画像のパスを取得し、文字列配列に保存します。
  • 画像をループします。
  • 特定の画像を取得し、Presentation.Images.Append() メソッドを使用して画像コレクションに追加します。
  • Presentation.Slides.Append() メソッドを使用して、ドキュメントにスライドを追加します。
  • ISlide.SlideBackground オブジェクトの下にあるプロパティを使用して、画像をスライドの背景として設定します。
  • Presentation.SaveToFile() メソッドを使用して、結果文書を保存します。
  • C#
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
using System.IO;

namespace ConvertImageToBackground
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentationオブジェクトを作成する
            Presentation presentation = new Presentation();

            //スライドのサイズの種類を設定する
            presentation.SlideSize.Type = SlideSizeType.Screen16x9;

            //デフォルトのスライドを削除する
            presentation.Slides.RemoveAt(0);

            //ファイルパスを文字列配列で取得する
            string[] picFiles = Directory.GetFiles(@"C:\Users\Administrator\Desktop\Images");

            //画像をループする
            for (int i = 0; i < picFiles.Length; i++)
            {
                //スライドを追加する
                ISlide slide = presentation.Slides.Append();

                //特定の画像を取得する
                string imageFile = picFiles[i];
                Image image = Image.FromFile(imageFile);

                //画像コレクションに追加する
                IImageData imageData = presentation.Images.Append(image);

                //画像をスライドの背景画像として設定する
                slide.SlideBackground.Type = BackgroundType.Custom;
                slide.SlideBackground.Fill.FillType = FillFormatType.Picture;
                slide.SlideBackground.Fill.PictureFill.FillType = PictureFillType.Stretch;
                slide.SlideBackground.Fill.PictureFill.Picture.EmbedImage = imageData;
            }

            //結果文書を保存する
            presentation.SaveToFile("ImagesToBackground.pptx", FileFormat.Pptx2013);
        }
    }
}

C#:画像(PNG、JPG、BMP など)を PowerPoint に変換する方法

画像を PowerPoint の図形に変換する

PowerPoint ファイルで画像を移動可能かつサイズ変更可能にしたい場合は、それらを図形として変換することができます。以下は、Spire.Presentation for .NET を使用して PowerPoint 文書内の画像を図形に変換する手順です。

  • Presentation オブジェクトを作成します。
  • スライドのサイズの種類を Sreen16x9 に設定します。
  • フォルダーから画像のパスを取得し、文字列配列に保存します。
  • 画像をループします。
  • 特定の画像を取得し、Presentation.Images.Append() メソッドを使用して画像コレクションに追加します。
  • Presentation.Slides.Append() メソッドを使用して、ドキュメントにスライドを追加します。
  • ISlide.Shapes.AppendShape() メソッドを使用して、スライドと同じサイズの図形を追加します。
  • IAutoShape.Fill オブジェクトの下にあるプロパティを使用して、図形を画像で塗りつぶします。
  • Presentation.SaveToFile() メソッドを使用して、結果文書を保存します。
  • C#
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
using System.IO;

namespace ConvertImageToShape
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentationオブジェクトを作成する
            Presentation presentation = new Presentation();

            //スライドのサイズの種類を設定する
            presentation.SlideSize.Type = SlideSizeType.Screen16x9;

            //デフォルトのスライドを削除する
            presentation.Slides.RemoveAt(0);

            //ファイルパスを文字列配列で取得する
            string[] picFiles = Directory.GetFiles(@"C:\Users\Administrator\Desktop\Images");

            //画像をループする
            for (int i = 0; i < picFiles.Length; i++)
            {
                //スライドを追加する
                ISlide slide = presentation.Slides.Append();

                //特定の画像を取得する
                string imageFile = picFiles[i];
                Image image = Image.FromFile(imageFile);

                //画像コレクションに追加する
                IImageData imageData = presentation.Images.Append(image);

                //スライドと同じサイズの図形を追加する
                IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(new PointF(0, 0), presentation.SlideSize.Size));

                //図形を画像で塗りつぶす
                shape.Line.FillType = FillFormatType.None;
                shape.Fill.FillType = FillFormatType.Picture;
                shape.Fill.PictureFill.FillType = PictureFillType.Stretch;
                shape.Fill.PictureFill.Picture.EmbedImage = imageData;
            }

            //結果文書を保存する
            presentation.SaveToFile("ImageToShape.pptx", FileFormat.Pptx2013);
        }
    }
}

C#:画像(PNG、JPG、BMP など)を PowerPoint に変換する方法

画像をカスタマスライドサイズの PowerPoint に変換する

もし画像のアスペクト比が 16:9 ではない場合や、標準のスライドサイズでない場合は、画像の実際のサイズに基づいてスライドを作成することができます。これにより、画像が過度に伸びたり圧縮されたりするのを防ぐことができます。以下は、Spire.Presentation for .NET を使用してカスタマイズされたスライドサイズで PowerPoint 文書に画像を変換する手順です。

  • Presentation オブジェクトを作成します。
  • PdfUnitConvertor オブジェクトを作成し、ピクセルをポイントに変換するために使用します。
  • フォルダーから画像のパスを取得し、文字列配列に保存します。
  • 画像をループします。
  • 特定の画像を取得し、Presentation.Images.Append() メソッドを使用して画像コレクションに追加します。
  • 画像の幅と高さを取得し、ポイントに変換します。
  • Presentation.SlideSize.Size プロパティを使用して、スライドサイズを画像のサイズに基づいて設定します。
  • Presentation.Slides.Append() メソッドを使用して、ドキュメントにスライドを追加します。
  • ISlide.SlideBackground オブジェクトの下にあるプロパティを使用して、画像をスライドの背景画像として設定します。
  • Presentation.SaveToFile() メソッドを使用して、結果文書を保存します。
  • C#
using Spire.Pdf.Graphics;
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
using System.IO;

namespace CustomSlideSize
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentationオブジェクトを作成する
            Presentation presentation = new Presentation();

            //デフォルトのスライドを削除する
            presentation.Slides.RemoveAt(0);

            //ファイルパスを文字列配列で取得する
            string[] picFiles = Directory.GetFiles(@"C:\Users\Administrator\Desktop\Image");

            //PdfUnitConvertor オブジェクトを作成する
            PdfUnitConvertor convertor = new PdfUnitConvertor();

            //画像をループする
            for (int i = 0; i < picFiles.Length; i++)
            {
                //特定の画像を取得する
                string imageFile = picFiles[i];
                Image image = Image.FromFile(imageFile);

                //画像コレクションに追加する 
                IImageData imageData = presentation.Images.Append(image);

                //画像の高さと幅をピクセル単位で取得する
                int height = imageData.Height;   
                int width = imageData.Width;

                //ピクセルをポイントに変換する
                float widthPoint = convertor.ConvertUnits(width, PdfGraphicsUnit.Pixel, PdfGraphicsUnit.Point);
                float heightPoint= convertor.ConvertUnits(height, PdfGraphicsUnit.Pixel, PdfGraphicsUnit.Point);

                //スライドのサイズを設定する
                presentation.SlideSize.Size = new SizeF(widthPoint, heightPoint);

                //スライドを追加する
                ISlide slide = presentation.Slides.Append();

                //画像をスライドの背景画像として設定する
                slide.SlideBackground.Type = BackgroundType.Custom;
                slide.SlideBackground.Fill.FillType = FillFormatType.Picture;
                slide.SlideBackground.Fill.PictureFill.FillType = PictureFillType.Stretch;
                slide.SlideBackground.Fill.PictureFill.Picture.EmbedImage = imageData;
            }

            //結果文書を保存する
            presentation.SaveToFile("CustomizeSlideSize.pptx", FileFormat.Pptx2013);
        }
    }
}

C#:画像(PNG、JPG、BMP など)を PowerPoint に変換する方法

一時ライセンスを申請する

結果ドキュメントから評価メッセージを削除したい場合、または機能制限を取り除く場合は、についてこのメールアドレスはスパムボットから保護されています。閲覧するにはJavaScriptを有効にする必要があります。にお問い合わせ、30 日間有効な一時ライセンスを取得してください。

Published in 変換
Tagged under

ODP ファイルは、画像、テキスト、メディア、およびトランジション効果を含むスライドで構成される OpenDocument Presentation ファイルです。このファイルは OpenOffice Impress、LibreOffice Impress、Microsoft PowerPoint などの指定されたプログラムでのみ開くことができますので、ODP ファイルをより多くのデバイスで閲覧可能にしたい場合は、PDF に変換することができます。この記事では、Spire.Presentation for .NET を使用して ODP ファイル PDF に変換する方法を示します。

Spire.Presentation for.NET をインストールします

まず、Spire.Presentation for .NET パッケージに含まれている DLL ファイルを .NET プロジェクトの参照として追加する必要があります。DLL ファイルは、このリンクからダウンロードするか、NuGet を介してインストールできます。

PM> Install-Package Spire.Presentation

OpenDocument Presentation を PDF に変換する

Spire.Presentation for .NET は、Presentation.LoadFromFile() メソッドを呼び出すことで ODP ファイルを PDF 形式で保存することができます。以下に、詳細な手順を示します。

  • Presentation インスタンスを作成します。
  • Presentation.LoadFromFile() メソッドを使用して、サンプル ODP ファイルをロードします。
  • Presentation.SaveToFile(string, FileFormat) メソッドを使用して、ODP ファイルを PDF として保存します。
  • C#
  • VB.NET
using Spire.Presentation;

namespace ODPtoPDF
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentation インスタンスを作成する
            Presentation presentation = new Presentation();

            //サンプル ODP ファイルをロードする
            presentation.LoadFromFile("Sample.odp", FileFormat.ODP);

            // ODPファイルをPDFとして保存する
            presentation.SaveToFile("ODPtoPDF.pdf", FileFormat.PDF);
            presentation.Dispose();
        }
    }
}
Imports Spire.Presentation

Namespace ODPtoPDF
    Class Program
        Private Shared Sub Main(ByVal args As String())

            'Presentation インスタンスを作成する
            Dim presentation As Presentation = New Presentation()

            'サンプル ODP ファイルをロードする
            presentation.LoadFromFile("Sample.odp", FileFormat.ODP)

            ' ODPファイルをPDFとして保存する
            presentation.SaveToFile("ODPtoPDF.pdf", FileFormat.PDF)
            presentation.Dispose()

        End Sub
    End Class
End Namespace

C#/VB.NET:ODP を PDF に変換する方法

一時ライセンスを申請する

結果ドキュメントから評価メッセージを削除したい場合、または機能制限を取り除く場合は、についてこのメールアドレスはスパムボットから保護されています。閲覧するにはJavaScriptを有効にする必要があります。にお問い合わせ、30 日間有効な一時ライセンスを取得してください。

Published in 変換
Tagged under

他人がオンラインで共有する PowerPoint ドキュメントを使用するには、表示する前にパソコンにダウンロードする必要があります。しかし、プレゼンテーションが非常に大きい場合、ダウンロードプロセスは非常に煩雑で時間がかかります。PowerPoint を HTML に変換するのは、オンラインで直接プレゼンテーションを見るための良い解決策です。この記事では、Spire.Presentation for .NET を使用して、C# および VB.NET で PowerPoint を HTML に変換する方法を示します。

Spire.Presentation for.NET をインストールします

まず、Spire.Presentation for .NET パッケージに含まれている DLL ファイルを .NET プロジェクトの参照として追加する必要があります。DLL ファイルは、このリンクからダウンロードするか、NuGet を介してインストールできます。

PM> Install-Package Spire.Presentation

PowerPoint プレゼンテーションを C# および VB.NET で HTML に変換する

Spire.Presentation for .NET では、Presentation.SaveToFile(string, FileFormat) メソッドを使用して、PowerPoint プレゼンテーションを PDFXPS、HTML などの他のファイル形式に変換します。次の手順では、Spire.Presentation for .NET を使用して PowerPoint プレゼンテーションを HTML に変換する方法を示します。

  • Presentation クラスのインスタンスを初期化します
  • Presentation.LoadFromFile(string) メソッドを使用して PowerPoint プレゼンテーションをロードします
  • Presentation.SaveToFile(string, FileFormat) メソッドを使用して、PowerPoint プレゼンテーションを HTML 形式で保存します。
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertPowerPointToHtml
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentationクラスのインスタンスを初期化する
            Presentation ppt = new Presentation();
            //PowerPointプレゼンテーションをロードする
            ppt.LoadFromFile(@"sample.pptx");

            //HTMLを出力するファイルパスを指定する
            string result = @"D:\output\PowerPointToHtml.html";

            //PowerPointプレゼンテーションをHTML形式で保存する 
            ppt.SaveToFile(result, FileFormat.Html);
        }
    }
}
Imports Spire.Presentation

Namespace ConvertPowerPointToHtml
    Friend Class Program
        Private Shared Sub Main(ByVal args As String())
            'Presentationクラスのインスタンスを初期化する
            Dim ppt As Presentation = New Presentation()
            'PowerPointプレゼンテーションをロードする
            ppt.LoadFromFile("sample.pptx")

            'HTMLを出力するファイルパスを指定する
            Dim result = "D:\output\PowerPointToHtml.html "

            'PowerPointプレゼンテーションをHTML形式で保存する
            ppt.SaveToFile(result, FileFormat.Html)
        End Sub
    End Class
End Namespace

C#/VB.NET:PowerPoint を HTML に変換する方法

特定の PowerPoint スライドを C# および VB.NET で HTML に変換する

場合によっては、プレゼンテーション全体ではなく、特定のスライドを HTML に変換する必要があります。Spire.Presentation は、PowerPoint スライドを HTML に変換する ISlide.SaveToFile(string, FileFormat) メソッドを提供しています。詳細な手順は次のとおりです。

  • Presentation クラスのインスタンスを初期化します
  • Presentation.LoadFromFile() メソッドを使用して PowerPoint プレゼンテーションをロードします
  • Presentation.Slides[int]プロパティを使用して、PowerPoint プレゼンテーション内の特定のスライドをインデックスで取得します。
  • ISlide.SaveToFile(string, FileFormat) メソッドを使用して、PowerPoint スライドを HTML 形式で保存します。
  • C#
  • VB.NET
using Spire.Presentation;
using System;

namespace ConvertPowerPointSlideToHtml
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentationクラスのインスタンスを初期化する
            Presentation presentation = new Presentation();
            //PowerPointプレゼンテーションをロードする
            presentation.LoadFromFile(@"sample.pptx");

            //最初のスライドを取得する
            ISlide slide = presentation.Slides[0];

            //HTMLを出力するファイルパスを指定する 
            String result = @"D:\output\SlideToHtml.html";

            //最初のスライドをHTML形式で保存する
            slide.SaveToFile(result, FileFormat.Html);
        }
    }
}
Imports Spire.Presentation

Namespace ConvertPowerPointSlideToHtml
    Friend Class Program
        Private Shared Sub Main(ByVal args As String())
            'Presentationクラスのインスタンスを初期化する
            Dim presentation As Presentation = New Presentation()
            ' PowerPointプレゼンテーションをロードする
            presentation.LoadFromFile("sample.pptx")

            '最初のスライドを取得する
            Dim slide As ISlide = presentation.Slides(0)

            'HTMLを出力するファイルパスを指定する
            Dim result = "D:\output\SlideToHtml.html "

            '最初のスライドをHTML形式で保存する
            slide.SaveToFile(result, FileFormat.Html)
        End Sub
    End Class
End Namespace

C#/VB.NET:PowerPoint を HTML に変換する方法

一時ライセンスを申請する

結果ドキュメントから評価メッセージを削除したい場合、または機能制限を取り除く場合は、についてこのメールアドレスはスパムボットから保護されています。閲覧するにはJavaScriptを有効にする必要があります。にお問い合わせ、30 日間有効な一時ライセンスを取得してください。

Published in 変換
Tagged under

さまざまな目的で、PowerPoint を画像に変換する必要があります。 たとえば、他のユーザーが PowerPoint ドキュメントの内容を編集できないようにします、PowerPoint ドキュメントのサムネイルを生成します、ソーシャル メディアで PowerPoint ドキュメントを共有します。この記事では、Spire.Presentation for .NET を使用して、C# および VB.NET で PowerPoint を画像に変換する方法を示します。

Spire.Presentation for.NET をインストールします

まず、Spire.Presentation for .NET パッケージに含まれている DLL ファイルを .NET プロジェクトの参照として追加する必要があります。DLL ファイルは、このリンクからダウンロードするか、NuGetを介してインストールできます。

PM> Install-Package Spire.Presentation

PowerPoint を JPG または PNG に変換する

Spire.Presentation for .NET が提供する ISlide.SaveAsImage() メソッドでは、スライドを PNG または JPG に変換することがサポートします。以下に詳細な変換手順を示します。

  • Presentation クラスのインスタンスを初期化します。
  • Presentation.LoadFromFile() メソッドを使用して PowerPoint ドキュメントをロードします。
  • PowerPoint ドキュメント内のすべてのスライドをループします。
  • ISlide.SaveAsImage() メソッドを使用して、スライドを System.Drawing.Image オブジェクトとして保存します。
  • Image.Save() メソッドを使用して、画像オブジェクトを PNG または JPG ファイルとして保存します。
  • C#
  • VB.NET
using Spire.Presentation;
using System.Drawing;

namespace ConvertPowerPointToJpgOrPngImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentationクラスのインスタンスを初期化する
            Presentation presentation = new Presentation();
            //PowerPointドキュメントをロードする
            presentation.LoadFromFile(@"Sample.pptx");

            int i = 0;
            //すべてのスライドをループする
            foreach(ISlide slide in presentation.Slides)
            {                 
                //画像オブジェクトをPNGとして保存する
                Image image = slide.SaveAsImage();
                string fileName = string.Format("ToImage-img-{0}.png", i);
                image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
                i++;
            }
        }
    }
}
Imports Spire.Presentation

Namespace ConvertPowerPointToJpgOrPngImage
    Friend Class Program
        Private Shared Sub Main(ByVal args As String())
            'Presentationクラスのインスタンスを初期化する
            Dim presentation As Presentation = New Presentation()
            'PowerPointドキュメントをロードする
            presentation.LoadFromFile("Sample.pptx")

            Dim i = 0
            'すべてのスライドをループする
            For Each slide As ISlide In presentation.Slides
                '画像をPNGとして保存する
                Dim image As Image = slide.SaveAsImage()
                Dim fileName = String.Format("ToImage-img-{0}.png", i)
                image.Save(fileName, Drawing.Imaging.ImageFormat.Png)
                i += 1
            Next
        End Sub
    End Class
End Namespace

C#/VB.NET:PowerPoint を画像に変換する方法(PNG、JPG、TIFF、EMF、SVG)

PowerPoint を TIFF に変換する

Spire.Presentation for .NET が提供する Presentation.SaveToFile(string, FileFormat) メソッドでは、PowerPoint を TIFF に変換することがサポートします。以下に詳細な変換手順を示します。

  • Presentationクラスのインスタンスを初期化します。
  • Presentation.LoadFromFile()メソッドを使用してPowerPointドキュメントをロードします。
  • Presentation.SaveToFile(string, FileFormat)メソッドを使用してPowerPointドキュメントをTIFFイメージに変換します。
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertPowerPointToTiffImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentationクラスのインスタンスを初期化する
            Presentation presentation = new Presentation();
            //PowerPointドキュメントをロードする
            presentation.LoadFromFile(@"Sample.pptx");

            //画像をTIFFとして保存する 
            presentation.SaveToFile("toTIFF.tiff", FileFormat.Tiff);
        }
    }
}
Imports Spire.Presentation

Namespace ConvertPowerPointToTiffImage
    Friend Class Program
        Private Shared Sub Main(ByVal args As String())
            'Presentationクラスのインスタンスを初期化する
            Dim presentation As Presentation = New Presentation()
            'PowerPointドキュメントをロードする
            presentation.LoadFromFile("Sample.pptx")

            '画像をTIFFとして保存する
            presentation.SaveToFile("toTIFF.tiff", FileFormat.Tiff)
        End Sub
    End Class
End Namespace

C#/VB.NET:PowerPoint を画像に変換する方法(PNG、JPG、TIFF、EMF、SVG)

PowerPoint を EMF に変換する

Spire.Presentation for .NET が提供する ISlide.SaveAsEMF() メソッドでは、スライドを EMF に変換することがサポートします。以下に詳細な変換手順を示します。

  • Presentation クラスのインスタンスを初期化します。
  • Presentation.LoadFromFile() メソッドを使用して PowerPoint ドキュメントをロードします。
  • PowerPoint ドキュメント内のすべてのスライドをループします。
  • ISlide.SaveAsEMF() メソッドを使用して、スライドを EMF として保存します。
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertPowerPointToEmfImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentationクラスのインスタンスを初期化する
            Presentation presentation = new Presentation();
            //PowerPointドキュメントをロードする
            presentation.LoadFromFile(@"Sample.pptx");

            int i = 0;
            //すべてのスライドをループする
            foreach (ISlide slide in presentation.Slides)
            {
                string fileName = string.Format("ToEmf-{0}.emf", i);
                //各スライドをEMFとして保存する
                slide.SaveAsEMF(fileName);
                //各スライドを指定した幅と高さのEMFとして保存する
                //slide.SaveAsEMF(fileName, 1075, 710);
                i++;
            }
        }
    }
}
Imports Spire.Presentation

Namespace ConvertPowerPointToEmfImage
    Friend Class Program
        Private Shared Sub Main(ByVal args As String())
            'Presentationクラスのインスタンスを初期化する
            Dim presentation As Presentation = New Presentation()
            'PowerPointドキュメントをロードする
            presentation.LoadFromFile("Sample.pptx")

            Dim i = 0
            'すべてのスライドをループする
            For Each slide As ISlide In presentation.Slides
                Dim fileName = String.Format("ToEmf-{0}.emf", i)
                '各スライドをEMFとして保存する
                slide.SaveAsEMF(fileName)
                '各スライドを指定した幅と高さのEMFとして保存する
                'slide.SaveAsEMF(fileName, 1075, 710);
                i += 1
            Next
        End Sub
    End Class
End Namespace

C#/VB.NET:PowerPoint を画像に変換する方法(PNG、JPG、TIFF、EMF、SVG)

PowerPoint を SVG に変換する

Spire.Presentation for .NET が提供する Presentation.SaveToSVG() メソッドは、PowerPoint を SVG に変換することができます。以下に詳細な変換手順を示します。

  • Presentation クラスのインスタンスを初期化します。
  • Presentation.LoadFromFile() メソッドを使用して PowerPoint ドキュメントをロードします。
  • Presentation.SaveToSVG() メソッドを使用して PowerPoint を SVG に変換し、結果をバイト配列キューに保存します。
  • キュー内のバイト配列をループします。
  • Queue.Dequeue() メソッドを使用して、キューの先頭にあるバイト配列を削除して返します。
  • FileStream クラスのインスタンスを初期化する。FileStream.Write() メソッドを使用してバイト配列を SVG ファイルに保存します。
  • C#
  • VB.NET
using Spire.Presentation;
using System.Collections.Generic;
using System.IO;

namespace ConvertPowerPointToSvgImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentationクラスのインスタンスを初期化する
            Presentation presentation = new Presentation();
            //PowerPointドキュメントをロードする
            presentation.LoadFromFile(@"Sample.pptx");

            //PowerPointをSVGに変換し、結果をバイト配列キューに保存する
            Queue svgBytes = presentation.SaveToSVG();
            int count = svgBytes.Count;
            //キュー内のバイト配列をループする
            for (int i = 0; i < count; i++)
            {
                //キューの先頭にあるバイト配列を削除して返する
                byte[] bt = svgBytes.Dequeue();
                //出力ファイル名を指定する
                string fileName = string.Format("ToSVG-{0}.svg", i);
                //FileStreamインスタンスを作成する
                FileStream fs = new FileStream(fileName, FileMode.Create);
                //SVGファイルへのバイト配列を保存する
                fs.Write(bt, 0, bt.Length);
            }
        }
    }
}
Imports Spire.Presentation
Imports System.Collections.Generic
Imports System.IO

Namespace ConvertPowerPointToSvgImage
    Friend Class Program
        Private Shared Sub Main(ByVal args As String())
            'Presentationクラスのインスタンスを初期化する
            Dim presentation As Presentation = New Presentation()
            'PowerPointドキュメントをロードする
            presentation.LoadFromFile("Sample.pptx")

            'PowerPointをSVGに変換し、結果をバイト配列キューに保存する
            Dim svgBytes As Queue(Of Byte()) = presentation.SaveToSVG()
            Dim count = svgBytes.Count
            'キュー内のバイト配列をループする
            For i = 0 To count - 1
                'キューの先頭にあるバイト配列を削除して返する
                Dim bt As Byte() = svgBytes.Dequeue()
                '出力ファイル名を指定する
                Dim fileName = String.Format("ToSVG-{0}.svg", i)
                'FileStreamインスタンスを作成する
                Dim fs As FileStream = New FileStream(fileName, FileMode.Create)
                'SVGファイルへのバイト配列を保存する
                fs.Write(bt, 0, bt.Length)
            Next
        End Sub
    End Class
End Namespace

C#/VB.NET:PowerPoint を画像に変換する方法(PNG、JPG、TIFF、EMF、SVG)

一時ライセンスを申請する

結果ドキュメントから評価メッセージを削除したい場合、または機能制限を取り除く場合は、についてこのメールアドレスはスパムボットから保護されています。閲覧するにはJavaScriptを有効にする必要があります。にお問い合わせ、30 日間有効な一時ライセンスを取得してください。

Published in 変換
Tagged under

XML Paper Specification (XPS) ドキュメント形式は、XML に基づいてデジタル文書の電子表現です。ドキュメントの内容やデザインをコンピュータ上で完全に維持するページ分けの固定レイアウト形式です。印刷や共有を容易にするために PowerPoint ドキュメントを XPS に変換する必要がある場合があります。この記事では、Spire.Presentation for .NET を使用して、C# および VB.NET で PowerPoint を XPS に変換する方法を示します。

Spire.Presentation for.NET をインストールします

まず、Spire.Presentation for .NET パッケージに含まれている DLL ファイルを .NET プロジェクトの参照として追加する必要があります。DLL ファイルは、このリンクからダウンロードするか、NuGetを介してインストールできます。

PM> Install-Package Spire.Presentation

PowerPoint を XPS に変換する

Spire.Presentation for .NET が提供する Presentation.SaveToFile(string,FileFormat) メソッドは、PowerPoint ドキュメントを XPS ドキュメントとして保存することをサポートします。詳細な変換の手順は次のとおりです。

  • Presentation インスタンスを作成します。
  • Presentation.LoadFromFile() メソッドを使用して、サンプル・ドキュメントをロードします。
  • Presentation.SaveToFile(string,FileFormat)メソッドを使用して PowerPoint ドキュメントを XPS に保存します。
  • C#
  • VB.NET
using Spire.Presentation;

namespace PowerPointtoXPS
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentationインスタンスを作成する
            Presentation presentation = new Presentation();

            //サンプル・ドキュメントをロードする
            presentation.LoadFromFile("test.pptx");

            //PowerPointドキュメントをXPSに保存する
            presentation.SaveToFile("toXPS.xps", FileFormat.XPS);
        }
    }
}
Imports Spire.Presentation

Namespace PowerPointtoPDF
    Class Program
        Private Shared Sub Main(ByVal args As String())

            'Presentationインスタンスを作成する
            Dim presentation As Presentation = New Presentation()

            'サンプル・ドキュメントをロードする
            presentation.LoadFromFile("test.pptx")

            'PowerPointドキュメントをXPSに保存する
            presentation.SaveToFile("toXPS.xps", FileFormat.XPS)
        End Sub
    End Class
End Namespace

C#/VB.NET:PowerPoint を XPS に変換する方法

一時ライセンスを申請する

結果ドキュメントから評価メッセージを削除したい場合、または機能制限を取り除く場合は、についてこのメールアドレスはスパムボットから保護されています。閲覧するにはJavaScriptを有効にする必要があります。にお問い合わせ、30 日間有効な一時ライセンスを取得してください。

Published in 変換
Tagged under

PDF ファイルは、特定のビューアを必要とせずに、ほとんどのアプリケーションで表示できるなど、ドキュメント共有の面で多くの利点があります。さらに、受信者が使用するソフトウェアやシステムに影響されることなく、作成者が適用するすべてのフォーマットを保持することができます。

PowerPoint プレゼンテーションをクロスプラットフォームで可能な限り多くのデバイスで読めるようにするには、PDF に変換するのが最適な方法です。この記事では、Spire.Presentation for .NET を使用して、C# および VB.NET で PowerPoint プレゼンテーションを PDF に変換する方法を示します。

Spire.Presentation for.NET をインストールします

まず、Spire.Presentation for .NET パッケージに含まれている DLL ファイルを .NET プロジェクトの参照として追加する必要があります。DLL ファイルは、このリンクからダウンロードするか、NuGet を介してインストールできます。

PM> Install-Package Spire.Presentation

PowerPoint プレゼンテーション全体をPDFに変換する方法

次の手順は、Spire.Presentation for .NET を使用して PowerPoint プレゼンテーション全体を PDF に変換する方法を示しています。

  • Presentation クラスのオブジェクトを作成します。
  • Presentation.LoadFromFile() メソッドを使用して、PowerPoint プレゼンテーションをロードします。
  • Presentation.SaveToFile(filePath, FileFormat.PDF) メソッドを使用して、ファイルを PDF として保存します。
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertPowerPointToPdf
{
    class Program
    {
        static void Main(string[] args)
        {
            // Presentationクラスのオブジェクトを作成する
            Presentation ppt = new Presentation();
            // PowerPointプレゼンテーションをロードする
            ppt.LoadFromFile(@"sample.pptx");

            //ファイルをPDFとして保存する
            ppt.SaveToFile("output1.pdf", FileFormat.PDF);
        }
    }
}
Imports Spire.Presentation

Namespace ConvertPowerPointToPdf
    Friend Class Program
        Private Shared Sub Main(ByVal args As String())
            ' Presentationクラスのオブジェクトを作成する
            Dim ppt As Presentation = New Presentation()
            ' PowerPointプレゼンテーションをロードする
            ppt.LoadFromFile("sample.pptx")

            'ファイルをPDFとして保存する
            ppt.SaveToFile("output1.pdf", FileFormat.PDF)
        End Sub
    End Class
End Namespace

C#/VB.NET:PowerPoint プレゼンテーションを PDF に変換する方法

PowerPoint プレゼンテーションの特定のスライドを PDF に変換する方法

次の手順は、Spire.Presentation for .NET を使用して PowerPoint プレゼンテーションの特定のスライドを PDF に変換する方法を示しています。

  • Presentation クラスのオブジェクトを作成します。
  • Presentation.LoadFromFile() メソッドを使用して PowerPoint プレゼンテーションをロードします。
  • Presentation.Slides[slideIndex] プロパティを使用して、特定のスライドを取得します。
  • ISlide.SaveToFile(filePath, FileFormat.PDF) メソッドを使用して、スライドを PDF として保存します。
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertSlidesToPdf
{
    class Program
    {
        static void Main(string[] args)
        {
            //Presentationクラスのオブジェクトを作成する
            Presentation ppt = new Presentation();
            // PowerPointプレゼンテーションをロードする
            ppt.LoadFromFile(@"sample.pptx");

            // 2枚目のスライドを取得する
            ISlide slide = ppt.Slides[1];

            //スライドをPDFとして保存する
            slide.SaveToFile("output2.pdf", FileFormat.PDF);
        }
    }
}
Imports Spire.Presentation

Namespace ConvertSlidesToPdf
    Friend Class Program
        Private Shared Sub Main(ByVal args As String())
            'Presentationクラスのオブジェクトを作成する
            Dim ppt As Presentation = New Presentation()
            ' PowerPointプレゼンテーションをロードする

            ppt.LoadFromFile("sample.pptx")

            '2枚目のスライドを取得する
            Dim slide As ISlide = ppt.Slides(1)

            'スライドをPDFとして保存する
            slide.SaveToFile("output2.pdf", FileFormat.PDF)
        End Sub
    End Class
End Namespace

C#/VB.NET:PowerPoint プレゼンテーションを PDF に変換する方法

一時ライセンスを申請する

結果ドキュメントから評価メッセージを削除したい場合、または機能制限を取り除く場合は、についてこのメールアドレスはスパムボットから保護されています。閲覧するにはJavaScriptを有効にする必要があります。 にお問い合わせ、30 日間有効な一時ライセンスを取得してください。

Published in 変換
Tagged under