JavaでPPTおよびPPTXをJPGに変換
オンライン PPT から JPG へのコンバータを探していますか?
Before jumping into the Java code, if you need a quick online tool to convert PowerPoint (PPT, PPTX) to JPG without coding, check out our online converter:
Aspose PPT to JPG Converter
If you’re a developer looking for a programmatic solution, continue reading to learn how to convert PowerPoint slides to JPG using Aspose.Slides for Java.
PowerPoint から JPG への変換について
With Aspose.Slides API you can convert PowerPoint PPT or PPTX presentation to JPG image. It is also possible to convert PPT/PPTX to JPEG, PNG or SVG. With this features it’s easy to implement your own presentation viewer, create the thumbnail for every slide. This may be useful if you want to protect presentation slides from copywriting, demonstrate presentation in read-only mode. Aspose.Slides allows to convert the whole presentation or a certain slide into image formats.

PowerPoint PPT/PPTX を JPG に変換する
Here are the steps to convert PPT/PPTX to JPG:
- Create an instance of Presentation type.
- Get the slide object of ISlide type from Presentation.getSlides() collection.
- Create the thumbnail of each slide and then convert it into JPG. ISlide.getImage(float scaleX, float scaleY) method is used to get a thumbnail of a slide, it returns Images object as a result. getImage method has to be called from the needed slide of ISlide type, the scales of the resulting thumbnail are passed into the method.
- After you get the slide thumbnail, call [IImage.save(String formatName, int imageFormat)](https://reference.aspose.com/slides/java/com.aspose.slides/IImage#save(String formatName, int imageFormat)) method from the thumbnail object. Pass the resulting file name and the image format into it.
Presentation pres = new Presentation("PowerPoint-Presentation.pptx");
try {
for (ISlide sld : pres.getSlides()) {
// フルスケール画像を作成します
IImage slideImage = sld.getImage(1f, 1f);
// JPEG形式で画像をディスクに保存します
try {
slideImage.save(String.format("Slide_%d.jpg", sld.getSlideNumber()), ImageFormat.Jpeg);
} finally {
if (slideImage != null) slideImage.dispose();
}
}
} finally {
if (pres != null) pres.dispose();
}
カスタムサイズで PowerPoint PPT/PPTX を JPG に変換する
To change the dimension of the resulting thumbnail and JPG image, you can set the ScaleX and ScaleY values by passing them into the ISlide.getImage(float scaleX, float scaleY) methods:
Presentation pres = new Presentation("PowerPoint-Presentation.pptx");
try {
// 次元を定義します
int desiredX = 1200;
int desiredY = 800;
// X と Y のスケーリングされた値を取得します
float ScaleX = (float) (1.0 / pres.getSlideSize().getSize().getWidth()) * desiredX;
float ScaleY = (float) (1.0 / pres.getSlideSize().getSize().getHeight()) * desiredY;
for (ISlide sld : pres.getSlides())
{
// フルスケール画像を作成します
IImage slideImage = sld.getImage(ScaleX, ScaleY);
// JPEG 形式で画像をディスクに保存します
try {
slideImage.save(String.format("Slide_%d.jpg", sld.getSlideNumber()), ImageFormat.Jpeg);
} finally {
if (slideImage != null) slideImage.dispose();
}
}
} finally {
if (pres != null) pres.dispose();
}
画像としてスライドを保存するときにコメントを描画する
Aspose.Slides for Java provides a facility that allows you to render comments in a presentation’s slides when you are converting those slides into images. This Java code demonstrates the operation:
Presentation pres = new Presentation("presentation.pptx");
try {
NotesCommentsLayoutingOptions notesOptions = new NotesCommentsLayoutingOptions();
notesOptions.setNotesPosition(NotesPositions.BottomTruncated);
IRenderingOptions opts = new RenderingOptions();
opts.setSlidesLayoutOptions(notesOptions);
for (ISlide sld : pres.getSlides()) {
IImage slideImage = sld.getImage(opts, new Dimension(740, 960));
try {
slideImage.save(String.format("Slide_%d.png", sld.getSlideNumber()));
} finally {
if (slideImage != null) slideImage.dispose();
}
}
} finally {
if (pres != null) pres.dispose();
}
Tip
Aspose provides a FREE Collage web app. Using this online service, you can merge JPG to JPG or PNG to PNG images, create photo grids, and so on.
Using the same principles described in this article, you can convert images from one format to another. For more information, see these pages: convert image to JPG; convert JPG to image; convert JPG to PNG, convert PNG to JPG; convert PNG to SVG, convert SVG to PNG.
FAQ
Does this method support batch conversion?
はい、Aspose.Slides は単一の操作で複数のスライドを JPG にバッチ変換できます。
Does the conversion support SmartArt, charts, and other complex objects?
はい、Aspose.Slides は SmartArt、チャート、テーブル、図形などすべてのコンテンツをレンダリングします。ただし、カスタムフォントや不足しているフォントを使用する場合、PowerPoint と比較して描画精度が若干異なることがあります。
Are there any limitations on the number of slides that can be processed?
Aspose.Slides 自体にはスライド数の厳格な制限はありませんが、大規模なプレゼンテーションや高解像度画像を扱う際にメモリ不足エラーが発生する可能性があります。
See Also
他の PPT/PPTX を画像に変換するオプションを見る: