Quản lý Zoom cho bản trình chiếu trong PHP

Giới thiệu

Zoom trong PowerPoint cho phép bạn di chuyển giữa các slide và phần cụ thể trong khi trình chiếu. Với Aspose.Slides cho PHP thông qua Java, bạn có thể tạo các zoom slide, phần và tổng quan và tùy chỉnh bản xem trước, viền và chuyển đổi của chúng.

Tổng quan zoom PowerPoint

  • Để tóm tắt toàn bộ bài thuyết trình trên một slide duy nhất, sử dụng Zoom Tổng quan.
  • Để chỉ hiển thị các slide đã chọn, sử dụng Zoom Slide.
  • Để chỉ hiển thị một phần duy nhất, sử dụng Zoom Phần.

Zoom Slide

Zoom slide có thể làm cho bài thuyết trình của bạn sinh động hơn, cho phép bạn di chuyển tự do giữa các slide theo bất kỳ thứ tự nào bạn muốn mà không làm gián đoạn luồng trình bày. Zoom slide rất phù hợp cho các bài thuyết trình ngắn không có nhiều phần, nhưng bạn vẫn có thể sử dụng chúng trong các kịch bản khác nhau.

Zoom slide cho phép bạn khám phá thông tin liên quan từ một slide tổng quan duy nhất.

Chọn các slide cho một zoom slide

Đối với các đối tượng zoom slide, Aspose.Slides cung cấp enum ZoomImageType, lớp ZoomFrame và các phương thức trên lớp ShapeCollection.

Tạo khung Zoom

Sử dụng ShapeCollection::addZoomFrame để đặt các liên kết tới các slide riêng lẻ trên một slide tổng quan. Ví dụ này tạo hai slide đích với nền và nhãn khác nhau, sau đó thêm bản xem trước của mỗi slide vào slide đầu tiên và lưu bài thuyết trình dưới dạng PPTX. Vị trí và kích thước của khung được chỉ định bằng điểm.

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();
}

Tạo khung Zoom với hình ảnh tùy chỉnh

Đưa một hình ảnh tùy chỉnh vào ShapeCollection::addZoomFrame để thay thế bản xem trước mặc định của slide đích. Ví dụ này yêu cầu một hình ảnh cục bộ, tải nó bằng Images::fromFile và thêm nó vào bài thuyết trình bằng ImageCollection::addImage. Khung kết quả hiển thị hình ảnh đó đồng thời vẫn liên kết tới slide thứ hai.

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();
}

Định dạng khung Zoom

Ví dụ này tùy chỉnh hai khung zoom slide. Nó gán một hình ảnh cục bộ cho khung đầu tiên thông qua ZoomObject::setZoomImage, và đặt cho khung thứ hai viền màu hồng dash‑dot có chiều rộng năm điểm bằng Shape::getLineFormat. Đặt false cho ZoomObject::setShowBackground sẽ ẩn nền của khung thứ hai. Một hình ảnh cục bộ là bắt buộc cho bản xem trước tùy chỉnh; cả hai khung vẫn giữ mục tiêu slide trong PPTX đã lưu.

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();
}

Zoom Phần

Zoom phần liên kết tới một phần trong bài thuyết trình của bạn. Sử dụng nó để quay lại một chủ đề hoặc hiển thị cách các phần khác nhau của bài thuyết trình liên kết với nhau.

Chọn một phần cho zoom phần

Đối với các đối tượng zoom phần, Aspose.Slides cung cấp lớp SectionZoomFrame và các phương thức trên lớp ShapeCollection.

Tạo khung Zoom Phần

Tạo một phần bằng SectionCollection::addSection, sau đó truyền phần đã trả về vào ShapeCollection::addSectionZoomFrame. Ví dụ này đặt một zoom phần trên slide đầu tiên và liên kết nó tới một phần bắt đầu bằng một slide có màu nền. Vị trí và kích thước của khung được chỉ định bằng điểm, và bài thuyết trình được lưu dưới dạng 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();
}

Tạo khung Zoom Phần với hình ảnh tùy chỉnh

Phiên bản nhận hình ảnh của ShapeCollection::addSectionZoomFrame cho phép bạn hiển thị bản xem trước tùy chỉnh mà không thay đổi phần đích. Ví dụ này yêu cầu một hình ảnh cục bộ, tải nó bằng Images::fromFile và thêm qua ImageCollection::addImage. Bài thuyết trình đã lưu chứa một zoom phần trên slide đầu tiên liên kết tới phần mới tạo.

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();
}

Thay đổi phần đích của Zoom Phần

Sử dụng SectionZoomFrame::setTargetSection để chuyển hướng một zoom phần hiện có mà không cần tạo lại. Chọn một phần đã được lấp đầy từ bộ sưu tập Presentation::getSections của cùng một bài thuyết trình. Gán một phần rỗng sẽ để nguyên mục tiêu hiện tại, vì vậy hãy kiểm tra Section::getSlidesListOfSection trước khi gán. Xem Quản lý các phần Slide để biết thêm chi tiết về các phần.

Ví dụ sau tải một tệp bài thuyết trình, tệp này phải chứa nhiều phần đã được lấp đầy, một zoom phần hiện có có tên Section navigation, và một phần có tên duy nhất Results. Nó tìm kiếm tất cả các slide để tìm zoom và xác định đích bằng tên thay vì bằng chỉ mục trong bộ sưu tập có thể thay đổi khi các phần được sắp xếp lại. Nếu tên không duy nhất, hãy sử dụng Section::getSectionId để xác định đích thay thế.

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();
}

Định dạng khung Zoom Phần

Ví dụ này di chuyển và thay đổi kích thước một zoom phần thành 100 × 75 điểm, gán một hình ảnh cục bộ qua ZoomObject::setZoomImage, và áp dụng viền màu nâu dash‑dot có độ dày 2,5 điểm. Nó bật ZoomObject::setReturnToParent để trở về slide gốc sau phần, tắt ZoomObject::setShowBackground, và đặt ZoomObject::setTransitionDuration thành 1,5 giây. Một hình ảnh cục bộ là bắt buộc cho bản xem trước tùy chỉnh.

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();
}

Zoom Tổng quan

Zoom tổng quan cung cấp một cái nhìn chung về các phần của bài thuyết trình. Trong quá trình trình chiếu, bạn có thể sử dụng nó để chuyển tới một phần, bỏ qua một đoạn, hoặc quay lại một chủ đề mà không cần tuân theo thứ tự slide.

Chọn các phần cho zoom tổng quan

Đối với các đối tượng zoom tổng quan, Aspose.Slides cung cấp các lớp SummaryZoomFrame, SummaryZoomSection và SummaryZoomSectionCollection, cùng các phương thức trên lớp ShapeCollection.

Tạo một Zoom Tổng quan

Sử dụng ShapeCollection::addSummaryZoomFrame để tạo một cái nhìn tổng quan về các phần của bài thuyết trình. Ví dụ này tạo bốn phần với nền slide khác nhau và thêm một zoom tổng quan vào slide đầu tiên. Vị trí và kích thước của khung được chỉ định bằng điểm, và cái nhìn tổng quan kết quả được lưu trong một bài thuyết trình 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();
}

Thêm và xoá một phần Zoom Tổng quan

Một zoom tổng quan lưu trữ các đối tượng SummaryZoomSection trong SummaryZoomFrame::getSummaryZoomCollection. Ví dụ này tạo một tổng quan của hai phần, thêm phần thứ ba bằng SummaryZoomSectionCollection::addSummaryZoomSection, và xoá mục của phần đầu tiên bằng SummaryZoomSectionCollection::removeSummaryZoomSection. Việc xoá mục không ảnh hưởng đến phần và các slide của bài thuyết trình.

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();
}

Định dạng các phần Zoom Tổng quan

Ví dụ này định dạng mục đầu tiên trong SummaryZoomFrame::getSummaryZoomCollection, sử dụng chỉ số dựa trên 0 là 0. Nó yêu cầu một hình ảnh cục bộ cho ZoomObject::setZoomImage, áp dụng viền đen dash‑dot có độ dày 1,5 điểm, và đặt ZoomObject::setTransitionDuration thành 1,5 giây. Đặt false cho ZoomObject::setReturnToParent sẽ tắt việc tự động quay lại slide tổng quan cho mục này.

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();
}

Câu hỏi thường gặp

Tôi có thể kiểm soát việc quay lại slide “cha” sau khi hiển thị mục tiêu không?

Có. Gọi ZoomObject::setReturnToParent với true để quay lại slide gốc sau khi nội dung mục tiêu được hiển thị.

Tôi có thể điều chỉnh “tốc độ” hoặc thời lượng của chuyển đổi Zoom không?

Có. Sử dụng ZoomObject::setTransitionDuration để kiểm soát thời lượng chuyển đổi tính bằng giây.

Có giới hạn số lượng đối tượng Zoom mà một bài thuyết trình có thể chứa không?

Hiện không có giới hạn API cứng nào được tài liệu đề cập. Giới hạn thực tế phụ thuộc vào độ phức tạp chung của bài thuyết trình và hiệu năng của trình xem. Bạn có thể thêm nhiều khung Zoom, nhưng nên cân nhắc kích thước tệp và thời gian render.