世俱杯 2025

PPT处理控件Aspose.Slides教程:在 PowerPoint 文件中创建 3D 形状

翻译|使用教程|编辑:吉炜炜|2025-02-14 13:27:22.487|阅读 29 次

概述:在PowerPoint文件中创建 3D 形状可以显著增强演示文稿的视觉吸引力。通过本教程将,你将学习如何使用 Aspose.Slides for Java,轻松地将 3D 模型渲染集成到应用程序中。

# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>

相关链接:

概述

在PowerPoint文件中创建 3D 形状可以显著增强演示文稿的视觉吸引力。此功能对于建筑、教育和设计等以视觉表现为关键的行业至关重要。通过使用 Aspose.Slides for Java,开发人员可以轻松地将 3D 模型渲染集成到他们的应用程序中。该库以其灵活性和高级自定义选项而闻名,使其成为在 PowerPoint 中创建 3D 形状的理想选择。凭借其强大的功能,Aspose.Slides for Java使开发人员能够以编程方式在 PowerPoint 中创建 3D 形状。

3D 模型渲染 - API 安装

要开始使用Aspose.Slides for Java ,可以这里下载或使用以下 Maven 配置:


<repository>
  <id>AsposeJavaAPI</id>
  <name>Aspose Java API</name>
  <url>//repository.aspose.com/repo/</url>
</repository>
<dependency>
  <groupId>com.aspose</groupId>
  <artifactId>aspose-slides</artifactId>
  <version>25.1</version>
  <classifier>jdk16</classifier>
</dependency>

以编程方式在 PowerPoint 文件中创建 3D 形状

按照以下步骤使用Aspose.Slides for Java在 PowerPoint 中创建 3D 形状

  1. 创建Presentation类的实例
  2. 通过调用addAutoShape方法创建一个新的 AutoShape,从默认模板对其进行调整并将其添加到集合的末尾。
  3. 调用setText方法设置 TextFrame 的纯文本。
  4. 通过调用setFontHeight方法设置字体高度
  5. 通过调用setCameraType函数定义相机类型
  6. 通过调用setRotation函数设置旋转。
  7. setLightType方法表示可以应用于形状的预设光照权。
  8. 定义挤压效果的方向、材料和高度。
  9. 调用保存方法将文件保存到磁盘。

以下代码片段演示了 Java 中的 3D 模型渲染:

public class main {
    public static void main(String[] args) {
        // Set the path for the working directory.
        String outPptxFile = "Presentation2.pptx";
        // Create an instance of the Presentation class. 
        Presentation pres = new Presentation();
        try
        {
            // Create a new AutoShape, tune it from default template and add it to the end of the collection.
            IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200);
            // Call the setText method to set the plain text for a TextFrame.
            shape.getTextFrame().setText("3D");
            // Set the font height by calling the setFontHeight method.
            shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(64);
            // Define the camera type by calling the setCameraType function. 
            shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront);
            // Set rotation by invoking the setRotation function.  
            shape.getThreeDFormat().getCamera().setRotation(20, 30, 40);
            // The setLightType method represents a preset light right that can be applied to a shape. 
            shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat);
            // Define direction, material and height of an extrusion effect.
            shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top);
            shape.getThreeDFormat().setMaterial(MaterialPresetType.Powder);
            shape.getThreeDFormat().setExtrusionHeight(100);
            // Call the save method to save the file onto the disk. 
            pres.save(outPptxFile, SaveFormat.Pptx);
        }
        finally
        {
            if (pres != null) pres.dispose();
        }
    }
}
输出:PowerPoint 中的 3D 绘图

结论

在 PowerPoint 中创建 3D 形状可以改变您的演示文稿,使其更具吸引力和信息量。通过使用Aspose.Slides for Java,开发人员可以轻松地将此功能集成到他们的应用程序中。它很容易上手,并且许可证允许开发人员和测试人员无限制地评估产品的功能。

常见问题 – 常见问题解答

如何使用 Aspose.Slides for Java 在 PowerPoint 中创建 3D 形状?

要创建 3D 形状,请初始化演示文稿,访问幻灯片,使用 添加 3D 形状IAutoShape,自定义它,然后保存演示文稿。请使用提供的作为指导。

使用 Aspose.Slides for Java 进行 3D 模型渲染有哪些好处?

Aspose.Slides for Java具有灵活性、易于集成以及高级定制选项,使其成为 PowerPoint 演示文稿中 3D 模型渲染的理想选择。

我可以在购买之前试用 Aspose.Slides for Java 吗?

是的,您可以从 Aspose官方网站或者联系Aspose官方授权代理商慧都科技获得免费试用许可证,探索 Aspose.Slides for Java 的功能和性能。

————————————————————————————————————————————

慧都是Aspose在中国的官方授权代理商,提供Aspose系列产品免费试用,咨询,正版销售等于一体的专业化服务。

下载|体验更多Aspose产品请咨询,或拨打产品热线:023-68661681

加入Aspose技术交流QQ群(666790229),与更多小伙伴一起探讨提升开发技能。

aspose下载



标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@dpuzeg.cn

文章转载自:慧都网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
相关产品
Aspose.Slides

Aspose.Slides是第一个能在用户的应用程序中对PowerPoint文档进行管理的组件。

Aspose.Slides for Reporting Services

Aspose.Slides for Reporting Services 是惟一的能在Microsoft SQL Server 2005和2008 Reporting Services 中以 Microsoft PowerPoint PPT 和 PPS 格式生成报表的解决方案。

Aspose.Slides for JasperReports

Aspose.Slides for JasperReports 是专门为JasperReports用户开发的一种标准组件,以帮助他们将其Java应用程序中的报表能够简单地导出为Microsoft PowerPoint Presentation (PPT)和Microsoft PowerPoint Show (PPS)格式。

Aspose.Slides for SharePoint

Aspose.Slides for SharePoint使您在一个SharePoint应用程序中读取和转换PowerPoint文件而不需要使用Microsoft PowerPoint。

扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP