チュートリアル

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

チュートリアル»pptjavaconversion

Displaying items by tag: pptjavaconversion

OpenDocument プレゼンテーション ドキュメント形式は、一般的に ODP と呼ばれ、Open Document Format ファイルのファイル拡張子の 1 つです。スライドショー プレゼンテーションのオープンソース表示形式として機能するように設計されています。ドキュメントの書式が維持されるようにするには、ODP ファイルを PDF に変換する必要がある場合があります。この記事では、Spire.Presentation for Java を使用してこの機能を実現する方法を説明します。

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

まず、Spire.Presentation for Java を Java プロジェクトに追加する必要があります。JAR ファイルは、このリンクからダウンロードできます。Maven を使用する場合は、次のコードをプロジェクトの pom.xml ファイルに追加する必要があります。

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.presentation</artifactId>
        <version>9.4.5</version>
    </dependency>
</dependencies>

ODP ファイルを PDF ファイルに変換

Spire.Presentation for Java を使用して ODP を PDF に変換するには、以下の手順に従って簡単かつ迅速に行うことができます。

  • Presentation オブジェクトを作成します。
  • Presentation.loadFromFile() メソッドを使用してサンプル ODP ドキュメントをロードします。
  • Presentation.saveToFile() メソッドを使用して、ドキュメントを PDF として保存します。
  • Java
import com.spire.presentation.*;

public class ODPtoPDF {
    public static void main(String[] args) throws Exception {

        // Presentationのインスタンスを作成する
        Presentation presentation = new Presentation();

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

        // PDFとして保存する
        presentation.saveToFile("output/ODPをPDFに変換.pdf", FileFormat.PDF);
    }
}

Java:ODP を PDF に変換する方法

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

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

Published in 変換
Tagged under

画像ファイルは、人々の日常生活で最もよく使われるドキュメントの一形態です。時折、特定のフォルダ内の全ての画像ファイルを取り出し、PowerPoint プレゼンテーション用のスライドに変換する必要が生じます。お客様の要件に応じて、画像をシェイプやスライドの背景に変換することが可能です。この記事では、Spire.Presentation for Java を使用して画像を PowerPoint ドキュメントに変換する方法を示します。

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

まず、Spire.Presentation for Java を Java プロジェクトに追加する必要があります。JAR ファイルは、このリンクからダウンロードできます。Maven を使用する場合は、次のコードをプロジェクトの pom.xml ファイルに追加する必要があります。

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.presentation</artifactId>
        <version>8.9.4</version>
    </dependency>
</dependencies>

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

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

  • Presentation オブジェクトを作成します。
  • スライドのサイズの種類を Sreen16x9 に設定します。
  • フォルダーから画像の パスを取得します。
  • 画像をループします。
  • Presentation.getImages().append() メソッドを使用して、特定の画像を取得し、ドキュメントの画像コレクションに追加します。
  • Presentation.getSlides().append() メソッドを使用して、ドキュメントにスライドを追加します。
  • SlideBackground オブジェクトの下にあるメソッドを使用して、画像をスライドの背景として設定します。
  • Presentation.saveToFile() メソッドを使用して、結果文書を保存します。
  • Java
import com.spire.presentation.*;
import com.spire.presentation.drawing.*;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;

public class ConvertImagesAsBackground {

    public static void main(String[] args) throws Exception {

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

        //スライドのサイズの種類を設定する
        presentation.getSlideSize().setType(SlideSizeType.SCREEN_16_X_9);

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

        //フォルダーから画像ファイルを取得する
        File directoryPath = new File("C:\\Users\\Administrator\\Desktop\\Images");
        File[] picFiles  = directoryPath.listFiles();

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

            //特定の画像を取得する
            String imageFile = picFiles[i].getAbsolutePath();

            //画像コレクションに追加する
            BufferedImage bufferedImage =  ImageIO.read(new FileInputStream(imageFile));
            IImageData imageData = presentation.getImages().append(bufferedImage);

            //画像をスライドの背景画像として設定する
            slide.getSlideBackground().setType(BackgroundType.CUSTOM);
            slide.getSlideBackground().getFill().setFillType(FillFormatType.PICTURE);
            slide.getSlideBackground().getFill().getPictureFill().setFillType(PictureFillType.STRETCH);
            slide.getSlideBackground().getFill().getPictureFill().getPicture().setEmbedImage(imageData);
        }

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

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

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

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

  • Presentation オブジェクトを作成します。
  • スライドのサイズの種類を Sreen16x9 に設定します。
  • フォルダーから画像のパスを取得します。
  • 画像をループします。
  • Presentation.getImages().append() メソッドを使用して、特定の画像を取得し、ドキュメントの画像コレクションに追加します。
  • Presentation.getSlides().append() メソッドを使用して、ドキュメントにスライドを追加します。
  • ISlide.getShapes().appendShape() メソッドを使用して、スライドと同じサイズの図形を追加します。
  • FillFormat オブジェクトの下にあるメソッドを使用して、図形を画像で塗りつぶします。
  • Presentation.saveToFile() メソッドを使用して、結果文書を保存します。
  • Java
import com.spire.presentation.*;
import com.spire.presentation.drawing.*;

import javax.imageio.ImageIO;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;

public class ConvertImageToShape {

    public static void main(String[] args) throws Exception {

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

        //スライドのサイズの種類を設定する
        presentation.getSlideSize().setType(SlideSizeType.SCREEN_16_X_9);

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

        //フォルダーから画像ファイルを取得する
        File directoryPath = new File("C:\\Users\\Administrator\\Desktop\\Images");
        File[] picFiles  = directoryPath.listFiles();

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

            //特定の画像を取得する
            String imageFile = picFiles[i].getAbsolutePath();

            //画像コレクションに追加する
            BufferedImage bufferedImage =  ImageIO.read(new FileInputStream(imageFile));
            IImageData imageData = presentation.getImages().append(bufferedImage);

            //スライドと同じサイズの図形を追加する
            IAutoShape shape = slide.getShapes().appendShape(ShapeType.RECTANGLE, new Rectangle2D.Float(0, 0, (float) presentation.getSlideSize().getSize().getWidth(), (float)presentation.getSlideSize().getSize().getHeight()));

            //図形を画像で塗りつぶす
            shape.getLine().setFillType(FillFormatType.NONE);
            shape.getFill().setFillType(FillFormatType.PICTURE);
            shape.getFill().getPictureFill().setFillType(PictureFillType.STRETCH);
            shape.getFill().getPictureFill().getPicture().setEmbedImage(imageData);
        }

        //結果文書を保存する
        presentation.saveToFile("ImagesToShape.pptx", FileFormat.PPTX_2013);
    }
}

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

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

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

  • Presentation オブジェクトを作成します。
  • PdfUnitConvertor オブジェクトを作成し、ピクセルをポイントに変換するために使用します。
  • フォルダから画像のパスを取得します。
  • 画像をループします。
  • Presentation.getImages().append() メソッドを使用して、特定の画像を取得し、ドキュメントの画像コレクションに追加します。
  • 画像の幅と高さを取得し、ポイントに変換します。
  • Presentation.getSlideSize().setSize() メソッドを使用して、スライドサイズを画像のサイズに基づいて設定します。
  • Presentation.getSlides().append() メソッドを使用して、ドキュメントにスライドを追加します。
  • SlideBackground オブジェクトの下にあるメソッドを使用して、画像をスライドの背景画像として設定します。
  • Presentation.saveToFile() メソッドを使用して、結果文書を保存します。
  • Java
import com.spire.pdf.graphics.PdfGraphicsUnit;
import com.spire.pdf.graphics.PdfUnitConvertor;
import com.spire.presentation.*;
import com.spire.presentation.drawing.*;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;

public class CustomizeSlideSize {

    public static void main(String[] args) throws Exception {

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

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

        //フォルダーから画像ファイルを取得する
        File directoryPath = new File("C:\\Users\\Administrator\\Desktop\\Images");
        File[] picFiles  = directoryPath.listFiles();

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

        //画像をループする
        for (int i = 0; i < picFiles.length; i++)
        {
            //特定の画像を取得する
            String imageFile = picFiles[i].getAbsolutePath();

            //画像コレクションに追加する
            BufferedImage bufferedImage =  ImageIO.read(new FileInputStream(imageFile));
            IImageData imageData = presentation.getImages().append(bufferedImage);

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

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

            //スライドのサイズを設定する
            presentation.getSlideSize().setSize(new Dimension((int)widthPoint, (int)heightPoint));

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

            //画像をスライドの背景画像として設定する
            slide.getSlideBackground().setType(BackgroundType.CUSTOM);
            slide.getSlideBackground().getFill().setFillType(FillFormatType.PICTURE);
            slide.getSlideBackground().getFill().getPictureFill().setFillType(PictureFillType.STRETCH);
            slide.getSlideBackground().getFill().getPictureFill().getPicture().setEmbedImage(imageData);
        }

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

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

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

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

Published in 変換
Tagged under

PowerPoint を HTML に変換することで、文書のアクセシビリティとインタラクティビティが最適化されます。PowerPoint のプレゼンテーションを HTML 形式に変換することで、さまざまなプラットフォームやデバイスで簡単に共有することができます。オンラインでスライドを共有するか、ウェブページにシームレスに統合するかに関係なく、PowerPoint を HTML に変換することは素晴らしい選択です。この記事では、Spire.Presentation for Java を使用して PowerPoint ファイルを HTML に変換する方法を示します。

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

まず、Spire.Presentation for Javaを Java プロジェクトに追加する必要があります。JAR ファイルは、このリンクからダウンロードできます。Maven を使用する場合は、次のコードをプロジェクトの pom.xml ファイルに追加する必要があります。

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.presentation</artifactId>
        <version>8.7.3</version>
    </dependency>
</dependencies>

PowerPoint プレゼンテーションを HTML に変換する

Spire.Presentation for Java を使用すると、PowerPoint ファイルを HTML 形式に変換することができます。詳細な手順は次のとおりです。

  • Presentationクラスのインスタンスを初期化します。
  • Presentation.loadFromFile() メソッドを使用してサンプルPowerPointファイルをロードします。
  • Presentation.saveToFile() メソッドを使用して、PowerPointプレゼンテーションを HTML として保存します。
  • Java
import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;

public class ToHtml {
    public static void main(String[] args) throws Exception {

        //Presentationクラスのインスタンスを初期化する
        Presentation presentation = new Presentation();

        //PowerPointファイルをロードする

        presentation.loadFromFile("sample.pptx");

        //ファイルをHTML形式で保存する
        presentation.saveToFile("ToHtml.html", FileFormat.HTML);
        presentation.dispose();
    }
}

Java:PowerPoint を HTML に変換する方法

特定の PowerPoint スライドを HTML に変換する

場合によっては、プレゼンテーション全体ではなく、特定のスライドを HTML に変換する必要があることがあります。そのような場合、Spire.Presentation for Java では、ISlide.saveToFile() メソッドを使用してスライドを HTML 形式に変換することができます。詳細な手順は次のとおりです。

  • Presentation クラスのインスタンスを初期化します。
  • Presentation.loadFromFile() メソッドを使用してサンプル PowerPoint ファイルをロードします。
  • Presentation.getSlides().get() メソッドを使用して特定のスライドを取得します。
  • ISlide.saveToFile() メソッドを使用して、PowerPoint スライドを HTML に保存します。
  • Java
import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;
import com.spire.presentation.ISlide;

public class ConvertSpecificSlideToHtml { public static void main(String[] args) throws Exception {

    //Presentationクラスのインスタンスを初期化する
    Presentation presentation = new Presentation();

    //PowerPointファイルをロードする
    presentation.loadFromFile("sample.pptx");

    //インデックスで特定のスライドを取得する
    ISlide slide = presentation.getSlides().get(1);

    //特定のスライドをHTML形式で保存する
    slide.saveToFile("SpecificSlideToHtml.html", FileFormat.HTML);
    slide.dispose();
}
}

Java:PowerPoint を HTML に変換する方法

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

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

Published in 変換
Tagged under

PowerPoint ドキュメントと比較して、画像ファイルは、特定のソフトウェアを必要とせずに、ほぼすべてのデバイスで開くことができるため、表示しやすくなっています。PowerPoint ドキュメントをさまざまなデバイスで利用できるようにしたい場合、画像に変換することができます。今回は、Spire.Presentation for Java を使用して、Java で PowerPoint ドキュメントをさまざまな画像形式に変換する方法を説明します。

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

まず、Spire.Presentation for Java を Java プロジェクトに追加する必要があります。JAR ファイルは、このリンクからダウンロードできます。Maven を使用する場合は、次のコードをプロジェクトの pom.xml ファイルに追加する必要があります。

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.presentation</artifactId>
        <version>7.10.1</version>
    </dependency>
</dependencies>

PowerPoint ドキュメントを JPG または PNG 画像に変換する

PowerPointドキュメントを JPG または PNG 画像に変換する手順は次のとおりです。

  • Presentation クラスのインスタンスを作成します。
  • Presentation.loadFromFile() メソッドを使用して PowerPoint ドキュメントを読み込みます。
  • PowerPoint ドキュメント内のすべてのスライドを循環させます。
  • ISlide.saveAsImage() メソッドを使用して、各スライドを BufferedImage クラスのオブジェクトとして保存します。
  • ImageIO.write() メソッドを使用して、BufferedImage クラスのオブジェクトを PNG ファイルまたは JPG ファイルに保存します。
  • Java
import com.spire.presentation.ISlide;
import com.spire.presentation.Presentation;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;

public class convertPowerPointToPngOrJpg {
    public static void main(String []args) throws Exception {

        //Presentationクラスのインスタンスを作成する
        Presentation presentation = new Presentation();

        //PowerPointドキュメントを読み込む
        presentation.loadFromFile("C:/Sample.pptx");

        //PowerPointドキュメント内の全スライドを循環させる
        for(int i = 0; i < presentation.getSlides().getCount(); i++)
        {
            ISlide slide = presentation.getSlides().get(i);

            //各スライドをPNG画像で保存する
            BufferedImage image = slide.saveAsImage();
            String fileName = String.format("画像-%1$s.png", i);
            ImageIO.write(image, "PNG",new File(fileName));
        }
    }
}

Java:PowerPoint を画像に変換する方法(PNG、JPG、TIFF、SVG)

PowerPoint ドキュメントを TIFF 画像に変換する

PowerPoint ドキュメントを TIFF 画像に変換する手順は次のとおりです。

  • Presentation クラスのインスタンスを作成します。
  • Presentation.loadFromFile() メソッドを使用して PowerPoint ドキュメントを読み込みます。
  • Presentation.saveToFile(String, FileFormat) メソッドを使用して、PowerPoint ドキュメントを TIFF 画像に変換します。
  • Java
import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;

public class convertPowerPointToTiff {
    public static void main(String []args) throws Exception {

        //Presentationクラスのインスタンスを作成する
        Presentation presentation = new Presentation();

        //PowerPointドキュメントを読み込む
        presentation.loadFromFile("C:/Sample.pptx");

        //PowerPointドキュメントをTIFF画像に変換する
        presentation.saveToFile("TIFF.tiff", FileFormat.TIFF);
    }
}

Java:PowerPoint を画像に変換する方法(PNG、JPG、TIFF、SVG)

PowerPointド キュメントを SVG 画像に変換する

PowerPoint ドキュメントを SVG 画像に変換する手順を説明します。

  • Presentation クラスのインスタンスを作成します。
  • Presentation.loadFromFile() メソッドを使用して PowerPoint ドキュメントを読み込みます。
  • Presentation.saveToSVG() メソッドを使用して、PowerPoint ドキュメントを SVG に変換し、その結果をバイト配列の ArrayList に保存します。
  • ArrayList 内のバイト配列をループ処理します。
  • ArrayList.get(int) メソッドを使用して、現在のバイト配列を取得します。
  • FileOutputStream クラスのインスタンスを作成し、FileOutputStream.write() メソッドを使用してバイト配列を SVG ファイルに保存します。
  • Java
import com.spire.presentation.Presentation;

import java.io.FileOutputStream;
import java.util.ArrayList;

public class convertPowerPointToSVG {
    public static void main(String []args) throws Exception {

        //Presentationクラスのインスタンスを作成する
        Presentation presentation = new Presentation();

        //PowerPointドキュメントを読み込む
        presentation.loadFromFile("C:/Sample.pptx");

        //PowerPointドキュメントをSVGに変換し、その結果をバイト配列のArrayListに保存する
        ArrayList svgBytes =(ArrayList) presentation.saveToSVG();
        int len = svgBytes.size();

        //ArrayListのバイト配列をループする
        for (int i = 0; i < len; i++)
        {
            //現在のバイト配列を取得する
            byte[] bytes = (byte[]) svgBytes.get(i);

            //出力ファイル名を指定する
            String fileName= String.format("ToSVG-%d.svg", i);

            //FileOutputStreamクラスのインスタンスを作成する
            FileOutputStream stream = new FileOutputStream(fileName);

            //バイト配列をSVGファイルに保存する
            stream.write(bytes);
        }
    }
}

Java:PowerPoint を画像に変換する方法(PNG、JPG、TIFF、SVG)

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

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

Published in 変換
Tagged under

XPS は固定ページレイアウトを持つファイル書式です。この書式は、ドキュメントの忠実度を維持し、デバイスに依存しないドキュメントの外観を提供することができます。PowerPoint ファイルを既存の形式で印刷したり、他の人に送信したりするには、XPS に変換することができます。この記事では、Spire.Presentation for Java を使用して PowerPoint を XPS に変換する方法を示します。以下に具体的な手順と方法を示します。

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

まず、Spire.Presentation for Java を Java プロジェクトに追加する必要があります。JAR ファイルは、このリンクからダウンロードできます。Maven を使用する場合は、次のコードをプロジェクトの pom.xml ファイルに追加する必要があります。

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.presentation</artifactId>
        <version>7.8.2</version>
    </dependency>
</dependencies>

PowerPoint のスライドを XPS に変換する方法

Spire.Presentation for Java が提供する Presentation.saveToFile(java.lang.String file, FileFormat fileFormat) メソッドは、スライドを XPS ファイル書式として保存します。具体的な手順は次のとおりです。

  • Presentation クラスのオブジェクトを作成します。
  • Presentation.loadFromFile() メソッドを使用して、PowerPoint プレゼンテーションをロードします。
  • Presentation.saveToFile() メソッドを使用して、ファイルを XPS として保存します。
  • Java
import com.spire.presentation.*;

public class PPTtoXPS {
    public static void main(String[] args) throws  Exception{
        // Presentationクラスのオブジェクトを作成する
        Presentation ppt = new Presentation();

        // PowerPointプレゼンテーションをロードする
        ppt.loadFromFile("input.pptx");

        //ファイルをXPSとして保存する
        ppt.saveToFile("ToXPS.xps",FileFormat.XPS);
        ppt.dispose();
    }
}

Java:PowerPoint を XPS に変換する方法

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

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

Published in 変換
Tagged under

PowerPoint プレゼンテーションを PDF に変換する場合、ドキュメントのレイアウトとフォーマットは固定されます。受信者は、Microsoft PowerPoint をインストールせずに変換されたドキュメントを表示できますが、勝手に変更することはできません。この記事では、Spire.Presentation for Java を使用して PowerPoint プレゼンテーションを PDF に変換する方法を示します。

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

まず、Spire.Presentation for Java を Java プロジェクトに追加する必要があります。JAR ファイルは、このリンクからダウンロードできます。Maven を使用する場合は、次のコードをプロジェクトの pom.xml ファイルに追加する必要があります。

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.presentation</artifactId>
        <version>7.8.2</version>
    </dependency>
</dependencies>

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

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

  • Presentation クラスのインスタンスを作成します。
  • Presentation.LoadFromFile() メソッドを使用して、PowerPoint プレゼンテーションをロードします。
  • Presentation.saveToFile(filePath, FileFormat.PDF) メソッドを使用して、ファイルを PDF として保存します。
  • Java
import com.spire.presentation.FileFormat;
import com.spire.presentation.ISlide;
import com.spire.presentation.Presentation;

public class ConvertPowerPointToPDF {
    public static void main(String []args) throws Exception {
        //Presentationクラスのインスタンスを作成する
        Presentation ppt = new Presentation();
        //PowerPointプレゼンテーションをロードする
        ppt.loadFromFile("Sample.pptx");

        //ファイルをPDFとして保存する
        ppt.saveToFile("ToPdf1.pdf", FileFormat.PDF);
    }
}

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

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

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

  • Presentation クラスのインスタンスを作成します。
  • Presentation.LoadFromFile() メソッドを使用して PowerPoint プレゼンテーションをロードします。
  • Presentation.getSlides().get(slideIndex) メソッドを使用して、インデックスで特定のスライドを取得します。
  • ISlide.saveToFile(filePath, FileFormat.PDF) メソッドを使用して、スライドを PDF として保存します。
  • Java
import com.spire.presentation.FileFormat;
import com.spire.presentation.ISlide;
import com.spire.presentation.Presentation;

public class ConvertSlidesToPDF {
    public static void main(String []args) throws Exception {
        //Presentationクラスのインスタンスを作成する
        Presentation ppt = new Presentation();
        //PowerPointプレゼンテーションをロードする
        ppt.loadFromFile("Sample.pptx");

        //2枚目のスライドを取得する
        ISlide slide= ppt.getSlides().get(1);

        //スライドをPDFとして保存する
        slide.saveToFile("ToPdf2.pdf", FileFormat.PDF);
    }
}

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

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

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

Published in 変換
Tagged under