Línea
Crear Línea Simple
Para agregar una línea simple a una diapositiva seleccionada de la presentación, siga los pasos a continuación:
- Cree una instancia de la clase Presentation.
- Obtenga la referencia de una diapositiva utilizando su índice.
- Agregue un AutoShape de tipo Línea usando el método AddAutoShape expuesto por el objeto Shapes.
- Escriba la presentación modificada como un archivo PPTX.
En el ejemplo que se muestra a continuación, hemos agregado una línea a la primera diapositiva de la presentación.
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); | |
Crear Línea en Forma de Flecha
Aspose.Slides para C++ también permite a los desarrolladores configurar algunas propiedades de la línea para que se vea más atractiva. Intentemos configurar algunas propiedades de una línea para que se vea como una flecha. Siga los pasos a continuación para hacerlo:
- Cree una instancia de la clase Presentation.
- Obtenga la referencia de una diapositiva utilizando su índice.
- Agregue un AutoShape de tipo Línea usando el método AddAutoShape expuesto por el objeto Shapes.
- Establezca el estilo de la línea en uno de los estilos ofrecidos por Aspose.Slides para C++.
- Establezca el ancho de la línea.
- Establezca el estilo de Dash de la línea en uno de los estilos ofrecidos por Aspose.Slides para C++.
- Establezca el estilo de Cabeza de Flecha y la longitud del punto de inicio de la línea.
- Establezca el estilo de Cabeza de Flecha y la longitud del punto final de la línea.
- Escriba la presentación modificada como un archivo PPTX.
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); | |