线
Contents
[
Hide
]
创建普通线
要在演示文稿的选定幻灯片中添加简单的普通线,请按照以下步骤操作:
- 创建一个 Presentation class 的实例。
- 通过使用其索引获得幻灯片的引用。
- 使用 AddAutoShape 方法向 Shapes 对象添加一个线型自动形状。
- 将修改后的演示文稿写入 PPTX 文件。
在下面的示例中,我们向演示文稿的第一张幻灯片添加了一条线。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C | |
// The path to the documents directory. | |
const String outPath = u"../out/AddPlainLineToSlide_out.pptx"; | |
const String templatePath = u"../templates/AltText.pptx"; | |
// Load the desired the presentation | |
SharedPtr<Presentation> pres = MakeObject<Presentation>(); | |
// Access first slide | |
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0); | |
// Add an autoshape of type line | |
SharedPtr<IAutoShape> shape = slide->get_Shapes()->AddAutoShape(ShapeType::Line, 50, 150, 300, 0); | |
//Write the PPTX to Disk | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |
创建箭头形状线
Aspose.Slides for C++ 还允许开发者配置线的某些属性,使其看起来更具吸引力。请按照以下步骤配置线的几个属性,使其看起来像箭头:
- 创建一个 Presentation class 的实例。
- 通过使用其索引获得幻灯片的引用。
- 使用 AddAutoShape 方法向 Shapes 对象添加一个线型自动形状。
- 将线条样式设置为 Aspose.Slides for C++ 提供的样式之一。
- 设置线条的宽度。
- 将线条的 Dash Style 设置为 Aspose.Slides for C++ 提供的样式之一。
- 设置线的起点的 Arrow Head Style 和长度。
- 设置线的终点的箭头样式和长度。
- 将修改后的演示文稿写入 PPTX 文件。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C | |
// The path to the documents directory. | |
const String outPath = u"../out/AddArrowShapedLineToSlide_out.pptx"; | |
const String templatePath = u"../templates/AltText.pptx"; | |
// Load the desired the presentation | |
SharedPtr<Presentation> pres = MakeObject<Presentation>(); | |
// Access first slide | |
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0); | |
// Add an autoshape of type line | |
SharedPtr<IAutoShape> shape = slide->get_Shapes()->AddAutoShape(ShapeType::Line, 50, 150, 300, 0); | |
// Apply some formatting on the line | |
shape->get_LineFormat()->set_Style(LineStyle::ThickBetweenThin); | |
shape->get_LineFormat()->set_Width(10); | |
shape->get_LineFormat()->set_DashStyle(LineDashStyle::DashDot); | |
shape->get_LineFormat()->set_BeginArrowheadLength(LineArrowheadLength::Short); | |
shape->get_LineFormat()->set_BeginArrowheadStyle(LineArrowheadStyle::Oval); | |
shape->get_LineFormat()->set_EndArrowheadLength(LineArrowheadLength::Long); | |
shape->get_LineFormat()->set_EndArrowheadStyle(LineArrowheadStyle::Triangle); | |
shape->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid); | |
shape->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Maroon()); | |
//Write the PPTX to Disk | |
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |