PHP でプレゼンテーションズームを管理する
導入
PowerPoint ズームを使用すると、スライドショー中に特定のスライドやセクション間をナビゲートできます。Aspose.Slides for PHP via Java を使うと、スライド、セクション、サマリー ズームを作成し、プレビュー、枠線、トランジションをカスタマイズできます。

- プレゼンテーション全体を 1 枚のスライドにまとめるには、サマリーズーム を使用します。
- 選択したスライドだけを表示するには、スライドズーム を使用します。
- 単一のセクションだけを表示するには、セクションズーム を使用します。
スライドズーム
スライドズームを使用すると、プレゼンテーションがより動的になり、任意の順序でスライド間を自由にナビゲートでき、プレゼンテーションの流れを中断せずに済みます。スライドズームは、セクションが少ない短いプレゼンテーションに最適ですが、さまざまなシナリオでも使用できます。
スライドズームを使えば、単一の概要スライドから関連情報を探索できます。

スライドズーム オブジェクトについては、Aspose.Slides が ZoomImageType 列挙型、ZoomFrame クラス、および ShapeCollection クラスのメソッドを提供します。
ズームフレームの作成
ShapeCollection::addZoomFrame を使用して、概要スライド上に個々のスライドへのリンクを配置します。この例では、背景とラベルが異なる 2 つのターゲット スライドを作成し、各スライドのプレビューを最初のスライドに追加して PPTX として保存します。フレームの位置とサイズはポイントで指定します。
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$secondSlide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$thirdSlide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$secondSlide->getBackground()->setType(BackgroundType::OwnBackground);
$secondSlide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$secondSlide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$textBox = $secondSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 200, 500, 200);
$textBox->getTextFrame()->setText("Second Slide");
$thirdSlide->getBackground()->setType(BackgroundType::OwnBackground);
$thirdSlide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 189, 183, 107);
$thirdSlide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$textBox = $thirdSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 200, 500, 200);
$textBox->getTextFrame()->setText("Third Slide");
$overviewSlide->getShapes()->addZoomFrame(20, 20, 250, 200, $secondSlide);
$overviewSlide->getShapes()->addZoomFrame(200, 250, 250, 200, $thirdSlide);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
カスタム画像付きズームフレームの作成
ShapeCollection::addZoomFrame にカスタム画像を渡すことで、ターゲット スライドのデフォルト プレビューを置き換えられます。この例ではローカル画像が必要で、Images::fromFile で読み込み、ImageCollection::addImage を使用してプレゼンテーションに追加します。結果のフレームはその画像を表示しながら、2 番目のスライドへのリンクを保持します。
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$textBox = $slide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 200, 500, 200);
$textBox->getTextFrame()->setText("Second Slide");
$image = Images::fromFile("image.png");
try {
$previewImage = $presentation->getImages()->addImage($image);
} finally {
$image->dispose();
}
$overviewSlide->getShapes()->addZoomFrame(20, 20, 300, 200, $slide, $previewImage);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
ズームフレームの書式設定
この例では 2 つのスライドズームフレームをカスタマイズします。最初のフレームには ZoomObject::setZoomImage でローカル画像を割り当て、2 番目のフレームには Shape::getLineFormat を使用して 5 ポイントのピンクの点線‑破線枠線を設定します。ZoomObject::setShowBackground に false を渡すと、2 番目のフレームの背景が非表示になります。カスタムプレビューにはローカル画像が必要です。両フレームは保存された PPTX でスライドターゲットを保持します。
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\LineDashStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
use aspose\slides\ShapeType;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$secondSlide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$thirdSlide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$secondSlide->getBackground()->setType(BackgroundType::OwnBackground);
$secondSlide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$secondSlide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$textBox = $secondSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 200, 500, 200);
$textBox->getTextFrame()->setText("Second Slide");
$thirdSlide->getBackground()->setType(BackgroundType::OwnBackground);
$thirdSlide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 189, 183, 107);
$thirdSlide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$textBox = $thirdSlide->getShapes()->addAutoShape(ShapeType::Rectangle, 100, 200, 500, 200);
$textBox->getTextFrame()->setText("Third Slide");
$firstZoomFrame = $overviewSlide->getShapes()->addZoomFrame(20, 20, 250, 200, $secondSlide);
$secondZoomFrame = $overviewSlide->getShapes()->addZoomFrame(200, 250, 250, 200, $thirdSlide);
$image = Images::fromFile("image.png");
try {
$previewImage = $presentation->getImages()->addImage($image);
} finally {
$image->dispose();
}
$firstZoomFrame->setZoomImage($previewImage);
$secondZoomFrame->getLineFormat()->setWidth(5);
$secondZoomFrame->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 255, 105, 180);
$secondZoomFrame->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor($color);
$secondZoomFrame->getLineFormat()->setDashStyle(LineDashStyle::DashDot);
$secondZoomFrame->setShowBackground(false);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
セクションズーム
セクションズームはプレゼンテーション内のセクションへリンクします。トピックを再訪したり、プレゼンテーションの異なる部分がどのように関連しているかを示すのに使用できます。

セクションズーム オブジェクトについては、Aspose.Slides が SectionZoomFrame クラスと ShapeCollection クラスのメソッドを提供します。
セクションズームフレームの作成
SectionCollection::addSection でセクションを作成し、返されたセクションを ShapeCollection::addSectionZoomFrame に渡します。この例では、最初のスライドにセクションズームを配置し、カラー スライドで始まるセクションへリンクします。フレームの位置とサイズはポイントで指定し、PPTX として保存します。
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 154, 205, 50);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$section = $presentation->getSections()->addSection("Section 1", $slide);
$sectionZoomFrame = $overviewSlide->getShapes()->addSectionZoomFrame(20, 20, 300, 200, $section);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
カスタム画像付きセクションズームフレームの作成
ShapeCollection::addSectionZoomFrame の画像オーバーロードを使用すると、宛先セクションを変更せずにカスタムプレビューを表示できます。この例ではローカル画像が必要で、Images::fromFile で読み込み、ImageCollection::addImage を介して追加します。保存されたプレゼンテーションは、最初のスライドに新しく作成したセクションへリンクしたセクションズームを含みます。
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 154, 205, 50);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$image = Images::fromFile("image.png");
try {
$previewImage = $presentation->getImages()->addImage($image);
} finally {
$image->dispose();
}
$section = $presentation->getSections()->addSection("Section 1", $slide);
$sectionZoomFrame = $overviewSlide->getShapes()->addSectionZoomFrame(20, 20, 300, 200, $section, $previewImage);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
セクションズームのターゲットセクションを変更する
SectionZoomFrame::setTargetSection を使用すると、セクションズームを再作成せずにリダイレクトできます。同じプレゼンテーションの Presentation::getSections コレクションから対象セクションを選択します。空のセクションを割り当てると現在のターゲットは変更されませんので、割り当てる前に Section::getSlidesListOfSection を確認してください。セクションの詳細は スライド セクションの管理 を参照してください。
以下の例では、複数のセクションが含まれ、Section navigation という名前の既存セクションズームと、Results という一意の名前を持つセクションがあるプレゼンテーション ファイルを読み込みます。すべてのスライドを検索してズームを見つけ、インデックスが変更される可能性があるコレクションインデックスではなく名前で宛先を特定します。名前が一意でない場合は、代わりに Section::getSectionId を使用して宛先を識別してください。
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation("section-zoom.pptx");
try {
$zoom = null;
$slideCount = java_values($presentation->getSlides()->size());
for ($i = 0; $i < $slideCount; $i++) {
$slide = $presentation->getSlides()->get_Item($i);
$shapeCount = java_values($slide->getShapes()->size());
for ($j = 0; $j < $shapeCount; $j++) {
$shape = $slide->getShapes()->get_Item($j);
if (java_instanceof($shape, new JavaClass("com.aspose.slides.ISectionZoomFrame")) && java_values($shape->getName()) === "Section navigation") {
$zoom = $shape;
break;
}
}
if ($zoom != null) {
break;
}
}
$targetSection = null;
$sectionCount = java_values($presentation->getSections()->size());
for ($i = 0; $i < $sectionCount; $i++) {
$section = $presentation->getSections()->get_Item($i);
if (java_values($section->getName()) === "Results") {
$targetSection = $section;
break;
}
}
if ($zoom == null || $targetSection == null) {
echo "The section zoom or destination section was not found.", PHP_EOL;
} else if (java_values($targetSection->getSlidesListOfSection()->size()) == 0) {
echo "The destination section is empty.", PHP_EOL;
} else {
$currentSection = $zoom->getTargetSection();
echo "Current section: " . (java_is_null($currentSection) ? "" : java_values($currentSection->getName())), PHP_EOL;
$zoom->setTargetSection($targetSection);
$presentation->save("section-zoom-updated.pptx", SaveFormat::Pptx);
}
} finally {
$presentation->dispose();
}
セクションズームフレームの書式設定
この例では、セクションズームを 100 × 75 ポイントに移動およびサイズ変更し、ZoomObject::setZoomImage でローカル画像を割り当て、2.5 ポイントの茶色の点線‑破線枠線を適用します。ZoomObject::setReturnToParent を有効にしてセクション終了後に元のスライドに戻り、ZoomObject::setShowBackground を無効にし、ZoomObject::setTransitionDuration を 1.5 秒に設定します。カスタムプレビューにはローカル画像が必要です。
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\LineDashStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 154, 205, 50);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$section = $presentation->getSections()->addSection("Section 1", $slide);
$sectionZoomFrame = $overviewSlide->getShapes()->addSectionZoomFrame(20, 20, 300, 200, $section);
$sectionZoomFrame->setX(100);
$sectionZoomFrame->setY(300);
$sectionZoomFrame->setWidth(100);
$sectionZoomFrame->setHeight(75);
$image = Images::fromFile("image.png");
try {
$previewImage = $presentation->getImages()->addImage($image);
} finally {
$image->dispose();
}
$sectionZoomFrame->setZoomImage($previewImage);
$sectionZoomFrame->setReturnToParent(true);
$sectionZoomFrame->setShowBackground(false);
$sectionZoomFrame->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 165, 42, 42);
$sectionZoomFrame->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor($color);
$sectionZoomFrame->getLineFormat()->setDashStyle(LineDashStyle::DashDot);
$sectionZoomFrame->getLineFormat()->setWidth(2.5);
$sectionZoomFrame->setTransitionDuration(1.5);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
サマリーズーム
サマリーズームはプレゼンテーションのセクション全体の概要を提供します。スライドショー中に、セクションへジャンプしたり、先へ進んだり、スライド順に従わずにトピックを再訪したりできます。

サマリーズーム オブジェクトについては、Aspose.Slides が SummaryZoomFrame、SummaryZoomSection、SummaryZoomSectionCollection クラスと、ShapeCollection クラスのメソッドを提供します。
サマリーズームの作成
ShapeCollection::addSummaryZoomFrame を使用して、プレゼンテーションのセクションの概要を作成します。この例では、背景が異なる 4 つのセクションを作成し、最初のスライドにサマリーズームを追加します。フレームの位置とサイズはポイントで指定し、結果の概要を PPTX プレゼンテーションとして保存します。
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 165, 42, 42);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 1", $slide);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 2", $slide);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 127, 255, 0);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 3", $slide);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 0, 100, 0);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 4", $slide);
$summaryZoomFrame = $overviewSlide->getShapes()->addSummaryZoomFrame(150, 50, 300, 200);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
サマリーズーム セクションの追加と削除
サマリーズームは SummaryZoomFrame::getSummaryZoomCollection に格納された SummaryZoomSection オブジェクトを使用します。この例では、2 つのセクションの概要を作成し、SummaryZoomSectionCollection::addSummaryZoomSection で 3 番目のセクションを追加し、SummaryZoomSectionCollection::removeSummaryZoomSection で最初のセクションのエントリを削除します。エントリを削除しても、プレゼンテーションのセクションとスライドはそのまま残ります。
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 165, 42, 42);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$firstSection = $presentation->getSections()->addSection("Section 1", $slide);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 2", $slide);
$summaryZoomFrame = $overviewSlide->getShapes()->addSummaryZoomFrame(150, 50, 300, 200);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 127, 255, 0);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$thirdSection = $presentation->getSections()->addSection("Section 3", $slide);
$summaryZoomFrame->getSummaryZoomCollection()->addSummaryZoomSection($thirdSection);
$summaryZoomFrame->getSummaryZoomCollection()->removeSummaryZoomSection($firstSection);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
サマリーズーム セクションの書式設定
この例では、SummaryZoomFrame::getSummaryZoomCollection の最初のエントリ(インデックス 0)の書式を設定します。ローカル画像が必要な ZoomObject::setZoomImage を使用し、1.5 ポイントの黒い点線‑破線枠線を適用し、ZoomObject::setTransitionDuration を 1.5 秒に設定します。ZoomObject::setReturnToParent に false を渡すと、このエントリの自動的なサマリースライドへの戻りが無効になります。
use aspose\slides\BackgroundType;
use aspose\slides\FillType;
use aspose\slides\Images;
use aspose\slides\LineDashStyle;
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$presentation = new Presentation();
try {
$overviewSlide = $presentation->getSlides()->get_Item(0);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$color = new Java("java.awt.Color", 165, 42, 42);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor($color);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 1", $slide);
$slide = $presentation->getSlides()->addEmptySlide($overviewSlide->getLayoutSlide());
$slide->getBackground()->getFillFormat()->setFillType(FillType::Solid);
$slide->getBackground()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->CYAN);
$slide->getBackground()->setType(BackgroundType::OwnBackground);
$presentation->getSections()->addSection("Section 2", $slide);
$summaryZoomFrame = $overviewSlide->getShapes()->addSummaryZoomFrame(150, 50, 300, 200);
$summarySection = $summaryZoomFrame->getSummaryZoomCollection()->get_Item(0);
$image = Images::fromFile("image.png");
try {
$previewImage = $presentation->getImages()->addImage($image);
} finally {
$image->dispose();
}
$summarySection->setZoomImage($previewImage);
$summarySection->setReturnToParent(false);
$summarySection->getLineFormat()->getFillFormat()->setFillType(FillType::Solid);
$summarySection->getLineFormat()->getFillFormat()->getSolidFillColor()->setColor(java("java.awt.Color")->BLACK);
$summarySection->getLineFormat()->setDashStyle(LineDashStyle::DashDot);
$summarySection->getLineFormat()->setWidth(1.5);
$summarySection->setTransitionDuration(1.5);
$presentation->save("presentation.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
FAQ
ターゲットを表示した後、‘親’ スライドに戻る制御はできますか?
はい。ZoomObject::setReturnToParent に true を指定すると、ターゲット コンテンツが表示された後に元のスライドに戻ります。
ズーム トランジションの「速度」や期間を調整できますか?
はい。ZoomObject::setTransitionDuration を使用して、トランジション時間(秒)を制御できます。
プレゼンテーションが保持できるズーム オブジェクトの数に制限はありますか?
ドキュメントに記載されたハードな API 制限はありません。実際の制限はプレゼンテーション全体の複雑さやビューアのパフォーマンスに依存します。多数のズームフレームを追加できますが、ファイルサイズや描画時間を考慮してください。