Java를 사용하여 PowerPoint에서 3D 효과 적용

PowerPoint의 3D 효과는 프레젠테이션을 보다 매력적으로 만들고 사용자의 관심을 끄는 데 사용됩니다. 따라서 프로그래밍 방식으로 프레젠테이션에 3D 개체를 추가해야 하는 요구 사항이 있을 수 있습니다. 이 기사에서는 Java의 PowerPoint PPT 또는 PPTX에서 3D 효과를 만드는 방법을 배웁니다. 3D 텍스트와 도형을 만들고 이미지에 3D 효과를 적용하는 방법을 보여줍니다.

PowerPoint PPT에서 3D 효과를 적용하는 Java API

Aspose.Slides for Java는 광범위한 프레젠테이션 조작 기능을 캡슐화하는 강력한 API입니다. API를 사용하여 대화형 프레젠테이션을 만들고 기존 PPT/PPTX 파일을 원활하게 조작할 수 있습니다. PowerPoint 프레젠테이션에서 3D 효과를 만들기 위해 이 API를 사용합니다.

API의 JAR을 다운로드하거나 다음 Maven 구성을 사용하여 설치할 수 있습니다.

저장소:

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>

의존:

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>22.1</version>
    <classifier>jdk16</classifier>
</dependency>

Java의 PowerPoint에서 3D 텍스트 만들기

다음은 Java를 사용하여 PowerPoint PPT에서 3D 텍스트 조각을 만드는 단계입니다.

다음 코드 샘플은 Java에서 PowerPoint PPT로 3D 텍스트를 만드는 방법을 보여줍니다.

// 프레젠테이션 만들기
Presentation pres = new Presentation();
try {
    // 직사각형 모양 추가
    IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200);

    // 텍스트 설정
    shape.getFillFormat().setFillType(FillType.NoFill);
    shape.getLineFormat().getFillFormat().setFillType(FillType.NoFill);
    shape.getTextFrame().setText("3D Text");

    // 텍스트 부분 추가 및 속성 설정
    Portion portion = (Portion)shape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0);
    portion.getPortionFormat().getFillFormat().setFillType(FillType.Pattern);
    portion.getPortionFormat().getFillFormat().getPatternFormat().getForeColor().setColor(new Color(255, 140, 0));
    portion.getPortionFormat().getFillFormat().getPatternFormat().getBackColor().setColor(Color.WHITE);
    portion.getPortionFormat().getFillFormat().getPatternFormat().setPatternStyle(PatternStyle.LargeGrid);

    // 도형 텍스트의 글꼴 크기 설정
    shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(128);

    // 텍스트 프레임 가져오기
    ITextFrame textFrame = shape.getTextFrame();

    // "Arch Up" WordArt 변환 효과 설정
    textFrame.getTextFrameFormat().setTransform(TextShapeType.ArchUp);

    // 3D 효과 적용
    textFrame.getTextFrameFormat().getThreeDFormat().setExtrusionHeight(3.5f);
    textFrame.getTextFrameFormat().getThreeDFormat().setDepth(3);
    textFrame.getTextFrameFormat().getThreeDFormat().setMaterial(MaterialPresetType.Plastic);
    textFrame.getTextFrameFormat().getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
    textFrame.getTextFrameFormat().getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Balanced);
    textFrame.getTextFrameFormat().getThreeDFormat().getLightRig().setRotation(0, 0, 40);		 
    textFrame.getTextFrameFormat().getThreeDFormat().getCamera().setCameraType(CameraPresetType.PerspectiveContrastingRightFacing);

    // 프레젠테이션 저장
    pres.save("3D-Text.pptx", SaveFormat.Pptx);
} finally {
    if (pres != null) pres.dispose();
}

다음 스크린샷은 위 코드 샘플의 출력을 보여줍니다.

Java의 PowerPoint에서 3D 텍스트 만들기

Java의 PowerPoint에서 3D 모양 만들기

텍스트와 마찬가지로 PowerPoint 프레젠테이션의 도형에 3D 효과를 적용할 수 있습니다. 다음은 Java를 사용하여 PowerPoint PPT에서 3D 모양을 만드는 단계입니다.

다음 코드 샘플은 Java를 사용하여 PowerPoint의 도형에 3D 효과를 적용하는 방법을 보여줍니다.

// 프레젠테이션 만들기
Presentation pres = new Presentation();
try {
    // 직사각형 모양 추가
    IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200);

    // 모양에 대한 텍스트 설정
    shape.getTextFrame().setText("3D");
    shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(64);

    // 3D 효과 적용
    shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
    shape.getThreeDFormat().getCamera().setRotation(20, 30, 40);
    shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat);
    shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
    shape.getThreeDFormat().setMaterial(MaterialPresetType.Flat);
    shape.getThreeDFormat().setExtrusionHeight(100);
    shape.getThreeDFormat().getExtrusionColor().setColor(Color.BLUE);

    // 프레젠테이션 저장
    pres.save("3D-Shape.pptx", SaveFormat.Pptx);
} finally {
    if (pres != null) pres.dispose();
}

다음은 이 코드를 실행한 후 얻은 3D 모양입니다.

Java의 PowerPoint에서 3D 모양 만들기

3D 모양에 대한 그라디언트 만들기

아래 단계에 따라 모양에 그라데이션 효과를 적용할 수도 있습니다.

다음 코드 샘플은 PowerPoint PPT의 도형에 그라데이션 효과를 적용하는 방법을 보여줍니다.

// 프레젠테이션 만들기
Presentation pres = new Presentation();
try {
    // 직사각형 모양 추가
    IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200);

    // 모양에 대한 텍스트 설정
    shape.getTextFrame().setText("3D");
    shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(64);

    shape.getFillFormat().setFillType(FillType.Gradient);
    shape.getFillFormat().getGradientFormat().getGradientStops().add(0, Color.BLUE);
    shape.getFillFormat().getGradientFormat().getGradientStops().add(100, Color.MAGENTA);

    // 3D 효과 적용
    shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
    shape.getThreeDFormat().getCamera().setRotation(10, 20, 30);
    shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat);
    shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
    shape.getThreeDFormat().setExtrusionHeight(150);
    shape.getThreeDFormat().getExtrusionColor().setColor(new Color(255, 140, 0));

    // 프레젠테이션 저장
    pres.save("3D-Shape-Gradient.pptx", SaveFormat.Pptx);
} finally {
    if (pres != null) pres.dispose();
}

다음은 그라데이션 효과를 적용한 3D 모양입니다.

Java에서 PPT의 3D 모양에 대한 그라디언트 만들기

Java에서 PowerPoint의 이미지에 3D 효과 적용

Java용 Aspose.Slides를 사용하면 이미지에 3D 효과를 적용할 수도 있습니다. 다음은 Java에서 이 작업을 수행하는 단계입니다.

Java를 사용하여 PPT의 이미지에 3D 효과를 적용하는 단계는 다음과 같습니다.

// 프레젠테이션 만들기
Presentation pres = new Presentation();
try {
    // 직사각형 모양 추가
    IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200);

    // 모양에 대한 이미지 설정
    shape.getFillFormat().setFillType(FillType.Picture);
    IPPImage picture = null;
    try {
        picture = pres.getImages().addImage(Files.readAllBytes(Paths.get("tiger.bmp")));
    } catch (IOException e) { }
    shape.getFillFormat().getPictureFillFormat().getPicture().setImage(picture);
    shape.getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);

    // 3D 효과 적용
    shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
    shape.getThreeDFormat().getCamera().setRotation(10, 20, 30);
    shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat);
    shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
    shape.getThreeDFormat().setExtrusionHeight(150);
    shape.getThreeDFormat().getExtrusionColor().setColor(Color.GRAY);

    // 프레젠테이션 저장
    pres.save("3D-Image.pptx", SaveFormat.Pptx);
} finally {
    if (pres != null) pres.dispose();
}

다음은 3D 효과를 적용한 결과 이미지입니다.

Java에서 PowerPoint의 이미지에 3D 효과 적용

무료 라이선스 받기

평가 제한 없이 Java용 Aspose.Slides를 사용할 수 있는 무료 임시 라이선스를 얻을 수 있습니다.

결론

이 기사에서는 Java를 사용하여 PowerPoint PPT/PPTX에서 3D 효과를 적용하는 방법을 배웠습니다. 코드 샘플을 사용하여 PPT 또는 PPTX 프레젠테이션에서 3D 텍스트 또는 모양을 만들고 이미지에 3D 효과를 적용하는 방법을 시연했습니다. 문서를 방문하여 Java용 Aspose.Slides에 대해 자세히 알아볼 수 있습니다. 또한 질문이나 질문을 포럼에 게시할 수 있습니다.

또한보십시오