没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:李显亮|2021-04-12 11:09:25.920|阅读 320 次
概述:PowerPoint提供了许多形状,例如直线,椭圆,矩形等。在本文中,将学习如何在PowerPoint演示文稿中自动操纵形状。特别是,本文将介绍如何使用Java在PowerPoint演示文稿中添加,连接,克隆或删除形状。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
PowerPoint演示文稿中的形状用于阐述特定点或创建诸如流程图之类的图。此外,形状的包含使该演示文稿更具吸引力。因此,PowerPoint提供了许多形状,例如直线,椭圆,矩形等。在本文中,将学习如何在PowerPoint演示文稿中自动操纵形状。特别是,本文将介绍如何使用Java在PowerPoint演示文稿中添加,连接,克隆或删除形状。
为了使用PowerPoint形状,我们将使用Aspose.Slides。它是一个功能强大的Java API,可让您无缝操作PowerPoint演示文稿。特别是,API使您可以创建,修改,阅读和转换演示文稿文档。
>>你可以点击这里下载Aspose.Slides for java最新版测试体验。
PowerPoint支持各种形状,您可以将它们添加到演示文稿幻灯片中。因此,Aspose.Slides for Java支持以下形状类型:
Connector、Ellipse、Flash、Group、Image、Line、Paragraph、Picture、Frame、Portion、Rectangle等。
Java的Aspose.Slides提供ShapeType类来指定要添加的形状的类型。以下是使用Java在PowerPoint演示文稿中添加特定形状的步骤。
下面的代码示例演示如何使用Java将形状添加到PowerPoint演示文稿中。
// Instantiate Presentation class that represents the PPTX Presentation pres = new Presentation(); // Get the first slide ISlide sld = pres.getSlides().get_Item(0); // Add AutoShape of ellipse type sld.getShapes().addAutoShape(ShapeType.Ellipse, 100, 150, 150, 100); // Write the PPTX file to disk pres.save("add_shape.pptx", SaveFormat.Pptx);
以下是执行此代码后将获得的输出。
连接器是用于连接两个形状的线。此外,连接器可以是直线或曲线。以下是在两个PowerPoint形状之间添加连接器的步骤。
下面的代码示例演示如何使用Java在PowerPoint中的两个形状之间添加连接器。
// Instantiate Presentation class that represents the PPTX file Presentation input = new Presentation(); // Access shapes collection for selected slide IShapeCollection shapes = input.getSlides().get_Item(0).getShapes(); // Add Autoshape Ellipse IAutoShape ellipse = shapes.addAutoShape(ShapeType.Ellipse, 0, 100, 100, 100); // Add Autoshape Rectangle IAutoShape rectangle = shapes.addAutoShape(ShapeType.Rectangle, 100, 300, 100, 100); // Add connector shape to slide shape collection IConnector connector = shapes.addConnector(ShapeType.BentConnector2, 0, 0, 10, 10); // Join Shapes to connectors connector.setStartShapeConnectedTo(ellipse); connector.setEndShapeConnectedTo(rectangle); connector.reroute(); // Save Presentation input.save("connect_shape.pptx", SaveFormat.Pptx);
以下是连接形状后PowerPoint演示文稿的屏幕截图。
您也可以克隆PowerPoint形状以创建其副本。以下是执行此操作的步骤。
下面的代码示例演示如何使用Java添加PowerPoint形状的克隆。
// Instantiate Presentation class that represents the PPTX Presentation pres = new Presentation(); // Get the first slide ISlide sld = pres.getSlides().get_Item(0); // Add AutoShape of rectangle type IShape shp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 75, 150); // Rotate the shape to 90 degree shp.setRotation(90); // Write the PPTX file to disk pres.save("clone_shape.pptx", SaveFormat.Pptx);
您也可以使用Aspose.Slides for Java从幻灯片中删除PowerPoint形状。以下是从形状集合中删除PowerPoint形状的步骤。
下面的代码示例演示如何使用Java从幻灯片中删除PowerPoint形状。
// Load presentation Presentation presentation1 = new Presentation("clone_shape.pptx"); // Get slide ISlide slide = presentation1.getSlides().get_Item(0); // Shape text to find the shape String alttext = "User Defined"; // Get number of shapes int iCount = slide.getShapes().size(); // Loop through shapes for (int i = 0; i < iCount; i++) { // Get shape IAutoShape ashp = (IAutoShape) slide.getShapes().get_Item(0); if (ashp.getAlternativeText().compareTo(alttext) == 0) { // Remove shape slide.getShapes().remove(ashp); } } presentation1.save("remove_shape.pptx", SaveFormat.Pptx);
如果你想试用Aspose的全部完整功能,可联系在线客服获取30天临时授权体验。
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@wqylolg.cn
可视化项目时间线对于有效规划和跟踪至关重要。在本篇博文中,您将学习如何使用 C# 在 Excel 中创建甘特图。只需几行代码,即可自动生成动态、美观的甘特图。
本文将为大家介绍DevExpress XAF如何将.NET Aspire集成到Blazor项目中,欢迎下载最新版组件体验!
在线协同文档编辑器ONLYOFFICE现已支持阿里通义千问( Qwen),带来先进的 AI 功能,实现更智能的文档编辑。本指南将向您展示如何将 Qwen 连接到 ONLYOFFICE,并充分利用其功能。
需要从 PDF 文档中删除特定页面?本快速指南将向您展示如何仅用几行代码删除不需要的页面。
Aspose.Slides是第一个能在用户的应用程序中对PowerPoint文档进行管理的组件。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@wqylolg.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢