Java의 PowerPoint에서 슬라이드 레이아웃 적용

7747 단어 freeslidelayoutjava
슬라이드 레이아웃은 서식, 위치 지정 및 자리 표시자가 포함된 "즉시 사용 가능한"슬라이드 템플릿입니다. 적절하게 구성된 슬라이드 레이아웃은 슬라이드 콘텐츠의 명확성과 가독성을 크게 향상시킵니다. 이 기사에서는 Java를 통해 PowerPoint에서 슬라이드 레이아웃을 적용하는 방법을 보여줍니다. (API: Free Spire.Presentation for Java)

설치
방법 1: Free Spire.Presentation for Java을 다운로드하고 압축을 풉니다. 그런 다음 Spire.Presentation.jar 파일을 종속성으로 프로젝트에 추가합니다.

방법 2: pom.xml에 다음 구성을 추가하여 maven 프로젝트에 jar 종속성을 추가할 수도 있습니다.

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


1# 제목 슬라이드 레이아웃 적용:

import com.spire.presentation.*;

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

        //Create an instance of presentation document
        Presentation ppt = new Presentation();

        //Remove the default slide
        ppt.getSlides().removeAt(0);

        //Append a slide and set its layout
        ISlide slide = ppt.getSlides().append(SlideLayoutType.TITLE);

        //Add content for Title and Text
        IAutoShape shape = (IAutoShape)slide.getShapes().get(0);
        shape.getTextFrame().setText("The Scarlet Letter");

        shape = (IAutoShape)slide.getShapes().get(1);
        shape.getTextFrame().setText("A Dark Romanticism Fiction");

        //Save the document
        ppt.saveToFile("SlideLayout.pptx", FileFormat.PPTX_2013);
        ppt.dispose();
    }
}




2# 11가지 다양한 슬라이드 레이아웃 적용:

import com.spire.presentation.*;

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

        //Create a PPT document
        Presentation presentation = new Presentation();

        //Remove the default slide
        presentation.getSlides().removeAt(0);

        //Loop through slide layouts
        for (SlideLayoutType type : SlideLayoutType.values())
        {
            //Append slide by specified slide layout
            presentation.getSlides().append(type);
        }

        //Save the document
        presentation.saveToFile("Result.pptx", FileFormat.PPTX_2013);
        presentation.dispose();
    }
}

좋은 웹페이지 즐겨찾기