Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 29, 2020 17:20
Show Gist options
  • Save aspose-com-gists/81aeb05e6d3a070aa76fdea22ed53bc7 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/81aeb05e6d3a070aa76fdea22ed53bc7 to your computer and use it in GitHub Desktop.
Aspose.Slides for C++
This gist exceeds the recommended number of files (~10). To access all files, please clone this gist.
Added Gist for Aspose.Slides for C++
const String templatePath = u"../templates/AccessSlides.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<IDocumentProperties> documentProperties = pres->get_DocumentProperties();
System::Console::WriteLine(u"Category : {0}" , documentProperties->get_Category());
System::Console::WriteLine(u"Current Status : {0}", documentProperties->get_ContentStatus());
System::Console::WriteLine(u"Creation Date : {0}", documentProperties->get_CreatedTime().ToString());
System::Console::WriteLine(u"Author : {0}", documentProperties->get_Author());
System::Console::WriteLine(u"Description : {0}", documentProperties->get_Comments());
System::Console::WriteLine(u"KeyWords : {0}", documentProperties->get_Keywords());
System::Console::WriteLine(u"Last Modified By : {0}", documentProperties->get_LastSavedBy());
System::Console::WriteLine(u"Supervisor : {0}", documentProperties->get_Manager());
System::Console::WriteLine(u"Modified Date : {0}", documentProperties->get_LastSavedTime().ToString());
System::Console::WriteLine(u"Presentation Format : {0}", documentProperties->get_PresentationFormat());
System::Console::WriteLine(u"Last Print Date : {0}",documentProperties->get_LastPrinted().ToString());
System::Console::WriteLine(u"Is Shared between producers : {0}", documentProperties->get_SharedDoc());
System::Console::WriteLine(u"Subject : {0}", documentProperties->get_Subject());
System::Console::WriteLine(u"Title : {0}", documentProperties->get_Title());
// The path to the documents directory.
const String templatePath = u"../templates/SmartArt.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Traverse through every shape inside first slide
for(int x=0;x<pres->get_Slides()->idx_get(0)->get_Shapes()->get_Count();x++)
{
SharedPtr<IShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(x);
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape))
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArt> smart = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArt>(shape);
// Traverse through all nodes inside SmartArt
for (int i = 0; i < smart->get_AllNodes()->get_Count(); i++)
{
// Accessing SmartArt node at index i
System::SharedPtr<Aspose::Slides::SmartArt::SmartArtNode> node0 = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtNode>(smart->get_AllNodes()->idx_get(i));
// Traversing through the child nodes in SmartArt node at index i
for (int j = 0; j < node0->get_ChildNodes()->get_Count(); j++)
{
// Accessing the child node in SmartArt node
System::SharedPtr<Aspose::Slides::SmartArt::SmartArtNode> node = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtNode>(node0->get_ChildNodes()->idx_get(j));
// Printing the SmartArt child node parameters
System::Console::WriteLine(u"j = " + node->get_TextFrame()->get_Text()+u", Text = "+ node->get_Level()+u", Position = "+ node->get_Position());
}
}
}
}
// The path to the documents directory.
const String outPath = u"../out/AccessChildNodeSpecificPosition_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::StackedList);
if (smart->get_AllNodes()->get_Count() > 0)
{
// Accessing SmartArt node at index 0
SharedPtr<Aspose::Slides::SmartArt::ISmartArtNode> node0 = smart->get_AllNodes()->idx_get(0);
//Accessing child node collection
auto nodeCollection =node0->get_ChildNodes();
SharedPtr<SmartArtNode> foundChild;
int position = 1;
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArtNode> node = node0->get_ChildNodes()->idx_get(position);
// Printing the SmartArt child node parameters
System::Console::WriteLine(u"j = " + node->get_TextFrame()->get_Text() + u", Text = " + node->get_Level() + u", Position = " + node->get_Position());
}
// The path to the documents directory.
//const String outPath = u"../out/EmbeddedVideoFrame_out.pptx";
const String templatePath = u"../templates/AltText.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
for (int i = 0; i < slide->get_Shapes()->get_Count(); i++)
{
// Accessing the shape collection of slides
System::SharedPtr<IShape> shape = slide->get_Shapes()->idx_get(i);
if (System::ObjectExt::Is<GroupShape>(shape))
{
// Accessing the group shape.
SharedPtr<GroupShape> grphShape = DynamicCast<Aspose::Slides::GroupShape>(shape);
for (int j = 0; j < grphShape->get_Shapes()->get_Count(); j++)
{
SharedPtr<IShape> shape2 = grphShape->get_Shapes()->idx_get(j);
String st = shape2->get_AlternativeText();
// Accessing the AltText property
System::Console::WriteLine(u"Shape Name : " + st);
}
}
}
// The path to the documents directory.
const String outPath = u"../templates/pres.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
for (int x = 0; x < pres->get_LayoutSlides()->get_Count(); x++)
{
SharedPtr<IShapeCollection> shapeCollection = pres->get_LayoutSlides()->idx_get(x)->get_Shapes();
for (int i = 0; i < shapeCollection->get_Count(); i++) {
SharedPtr<IShape> shape = shapeCollection->idx_get(i);
System::Console::WriteLine(shape->get_FillFormat());
}
for (int j = 0; j < shapeCollection->get_Count(); j++) {
SharedPtr<IShape> shape = shapeCollection->idx_get(j);
System::Console::WriteLine(shape->get_LineFormat());
}
}
const String templatePath = u"../templates/AccessModifyingProperties.pptx";
System::SharedPtr<Presentation> presentation = System::MakeObject<Presentation>(templatePath);
// Create a reference to DocumentProperties object associated with Prsentation
System::SharedPtr<IDocumentProperties> documentProperties = presentation->get_DocumentProperties();
for (int32_t i = 0; i < documentProperties->get_CountOfCustomProperties(); i++)
{
System::Console::WriteLine(u"Custom Property Name : {0}", documentProperties->GetCustomPropertyName(i));
System::Console::WriteLine(u"Custom Property Vlaue : {0}", documentProperties->idx_get(documentProperties->GetCustomPropertyName(i)));
}
// The path to the documents directory.
const String outPath = u"../out/excelFromOLE_out.xlsx";
const String templatePath = u"../templates/AccessingOLEObjectFrame.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Cast the shape to OleObjectFrame
SharedPtr<OleObjectFrame> oof = DynamicCast<Aspose::Slides::OleObjectFrame>(slide->get_Shapes()->idx_get(0));
// Read the OLE Object and write it to disk
if (oof != NULL)
{
System::ArrayPtr<uint8_t> buffer = oof->get_ObjectData();
{
System::SharedPtr<System::IO::FileStream> stream = System::MakeObject<System::IO::FileStream>(outPath, System::IO::FileMode::Create, System::IO::FileAccess::Write, System::IO::FileShare::Read);
stream->Flush();
stream->Close();
}
}
// The path to the documents directory.
// The path to the documents directory.
const String outPath = u"../out/AccessOpenDoc_out.pptx";
const String dataDir = u"../templates/AccessOpenDoc.odp";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(dataDir);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>();
System::SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
for (int x = 0; x < slide->get_Slide()->get_Shapes()->get_Count(); x++)
{
System::SharedPtr<IShape> shape = slide->get_Slide()->get_Shapes()->idx_get(x);
if (shape->get_Placeholder() != NULL) {
String text = u"";
if (shape->get_Placeholder()->get_Type() == PlaceholderType::CenteredTitle) // title - the text is empty, PowerPoint displays "Click to add title".
{
text = u"Click to add title";
}
else if (shape->get_Placeholder()->get_Type() == PlaceholderType::Subtitle) // the same for subtitle.
{
text = u"Click to add subtitle";
}
System::Console::WriteLine(u"Placeholder with text: {0}", text);
}
}
pres->Save(u"../out/Placeholders_PromptText.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
const String templatePath = u"../templates/AccessProperties.pptx";
System::SharedPtr<LoadOptions> loadOptions = System::MakeObject<LoadOptions>();
loadOptions->set_Password(u"pass");
loadOptions->set_OnlyLoadDocumentProperties ( true);
System::SharedPtr<Presentation> presentation = System::MakeObject<Presentation>(templatePath, loadOptions);
System::SharedPtr<IDocumentProperties> docProps = presentation->get_DocumentProperties();
System::Console::WriteLine(u"Name of Application : {0}", docProps->get_NameOfApplication());
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Getting Slide ID
int id = pres->get_Slides()->idx_get(0)->get_SlideId();
// Accessing Slide by ID
SharedPtr<IBaseSlide> slide = pres->GetSlideById(id);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Accessing Slide by ID
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// The path to the documents directory.
const String templatePath = u"../templates/Comments1.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Accessing comments collection
const int commentsCount = pres->get_CommentAuthors()->get_Count();
for (int i = 0; i < commentsCount; i++)
{
auto author = pres->get_CommentAuthors()->idx_get(i);
//std::cout << "Comments from: " << author->get_Name() << std::endl;
System::Console::WriteLine(u"Comments from: " + author->get_Name());
for (int j = 0; j < author->get_Comments()->get_Count(); j++)
{
auto comment = author->get_Comments()->idx_get(j);
System::Console::WriteLine(u"Comment: " + comment->get_Text());
}
}
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
// Instantiate Presentation class that represents the presentation file
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Instantiate SlideCollection calss
SharedPtr<ISlideCollection> slds = pres->get_Slides();
// Accessing a slide using its slide index
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
//Prinitng slide number
printf("Accessed Slide Number : %d\n", slide->get_SlideNumber());
// The path to the documents directory.
const String templatePath = u"../templates/SmartArt.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Traverse through every shape inside first slide
//foreach(IShape shape in pres.Slides[0].Shapes)
for (int x = 0; x<pres->get_Slides()->idx_get(0)->get_Shapes()->get_Count(); x++)
{
SharedPtr<IShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(x);
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape))
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArt> smart = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArt>(shape);
// Traverse through all nodes inside SmartArt
for (int i = 0; i < smart->get_AllNodes()->get_Count(); i++)
{
// Accessing SmartArt node at index i
System::SharedPtr<Aspose::Slides::SmartArt::SmartArtNode> node = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtNode>(smart->get_AllNodes()->idx_get(i));
// Printing the SmartArt node parameters
System::Console::WriteLine(u"j = " + node->get_TextFrame()->get_Text() + u", Text = " + node->get_Level() + u", Position = " + node->get_Position());
}
}
}
// The path to the documents directory.
const String templatePath = u"../templates/SmartArt.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Traverse through every shape inside first slide
for (int x = 0; x < pres->get_Slides()->idx_get(0)->get_Shapes()->get_Count(); x++)
{
SharedPtr<IShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(x);
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape))
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArt> smart = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArt>(shape);
System::Console::WriteLine(u"Smart Art Name = " + smart->get_Name());
// Checking SmartArt Layout
if (smart->get_Layout() == SmartArtLayoutType::BasicBlockList)
{
System::Console::WriteLine(u"Do some thing here....");
}
}
}
// The path to the documents directory.
const String templatePath = u"../templates/SmartArt.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Traverse through every shape inside first slide
for (int x = 0; x < pres->get_Slides()->idx_get(0)->get_Shapes()->get_Count(); x++)
{
SharedPtr<IShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(x);
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape))
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArt> smart = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArt>(shape);
System::Console::WriteLine(u"Smart Art Name = " + smart->get_Name());
}
}
// The path to the documents directory.
const String outPath = u"../out/AddArrowShapedLine_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);
// 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);
// The path to the documents directory.
const String outPath = u"../out/AudioFrameEmbed_out.pptx";
const String filePath = u"../templates/sampleaudio.wav";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Load the wav sound file to stream
System::SharedPtr<System::IO::FileStream> stream = System::MakeObject<System::IO::FileStream>(filePath, System::IO::FileMode::Open, System::IO::FileAccess::Read);
// Add Audio Frame
System::SharedPtr<IAudioFrame> af = slide->get_Shapes()->AddAudioFrameEmbedded(50, 150, 100, 100, stream);
// Set Play Mode and Volume of the Audio
af->set_PlayMode(AudioPlayModePreset::Auto);
af->set_Volume (AudioVolumeMode::Loud);
//Write the PPTX file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// supposed we have the large image file we want to include into the presentation
System::String pathToLargeImage = u"../templates/largeImage.jpg";
// create a new presentation which will contain this image
auto pres = System::MakeObject<Presentation>();
auto fileStream = System::MakeObject<System::IO::FileStream>(pathToLargeImage, System::IO::FileMode::Open);
// let's add the image to the presentation - we choose KeepLocked behavior, because we not
// have an intent to access the "largeImage.png" file.
auto img = pres->get_Images()->AddImage(fileStream, LoadingStreamBehavior::KeepLocked);
pres->get_Slides()->idx_get(0)->get_Shapes()->AddPictureFrame(Aspose::Slides::ShapeType::Rectangle, 0.0f, 0.0f, 300.0f, 200.0f, img);
// save the presentation. Despite that the output presentation will be
// large, the memory consumption will be low the whole lifetime of the pres object
pres->Save(u"../out/presentationWithLargeImage.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddBlobToPresentation_out.pptx";
const String filePath = u"../templates/Wildlife.mp4";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
//Loading very large video
auto data = GetFileByteData(filePath);
// Load the video file to stream
System::SharedPtr<System::IO::Stream> stream = System::MakeObject<System::IO::FileStream>(filePath, System::IO::FileMode::Open, System::IO::FileAccess::Read);
// Embedd vide inside presentation
System::SharedPtr<IVideo> video = pres->get_Videos()->AddVideo(stream, LoadingStreamBehavior::KeepLocked);
//Adding video
slide->get_Shapes()->AddVideoFrame(0, 0, 480, 270, video);
//Write the PPTX file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/BoxAndWhisker_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
System::SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::BoxAndWhisker, 50, 50, 500, 400);
chart->get_ChartData()->get_Categories()->Clear();
chart->get_ChartData()->get_Series()->Clear();
System::SharedPtr<IChartDataWorkbook> wb = chart->get_ChartData()->get_ChartDataWorkbook();
wb->Clear(0);
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A1", System::ObjectExt::Box<System::String>(u"Category 1")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A2", System::ObjectExt::Box<System::String>(u"Category 1")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A3", System::ObjectExt::Box<System::String>(u"Category 1")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A4", System::ObjectExt::Box<System::String>(u"Category 1")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A5", System::ObjectExt::Box<System::String>(u"Category 1")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A6", System::ObjectExt::Box<System::String>(u"Category 1")));
System::SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->Add(Aspose::Slides::Charts::ChartType::BoxAndWhisker);
series->set_QuartileMethod(Aspose::Slides::Charts::QuartileMethodType::Exclusive);
series->set_ShowMeanLine(true);
series->set_ShowMeanMarkers(true);
series->set_ShowInnerPoints(true);
series->set_ShowOutlierPoints(true);
series->get_DataPoints()->AddDataPointForBoxAndWhiskerSeries(wb->GetCell(0, u"B1", System::ObjectExt::Box<int32_t>(15)));
series->get_DataPoints()->AddDataPointForBoxAndWhiskerSeries(wb->GetCell(0, u"B2", System::ObjectExt::Box<int32_t>(41)));
series->get_DataPoints()->AddDataPointForBoxAndWhiskerSeries(wb->GetCell(0, u"B3", System::ObjectExt::Box<int32_t>(16)));
series->get_DataPoints()->AddDataPointForBoxAndWhiskerSeries(wb->GetCell(0, u"B4", System::ObjectExt::Box<int32_t>(10)));
series->get_DataPoints()->AddDataPointForBoxAndWhiskerSeries(wb->GetCell(0, u"B5", System::ObjectExt::Box<int32_t>(23)));
series->get_DataPoints()->AddDataPointForBoxAndWhiskerSeries(wb->GetCell(0, u"B6", System::ObjectExt::Box<int32_t>(16)));
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String outPath = u"../out/AddColorToDataPoints.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>();
System::SharedPtr<IChart> chart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Sunburst, 100.0f, 100.0f, 450.0f, 400.0f);
System::SharedPtr<IChartDataPointCollection> dataPoints = chart->get_ChartData()->get_Series()->idx_get(0)->get_DataPoints();
dataPoints->idx_get(3)->get_DataPointLevels()->idx_get(0)->get_Label()->get_DataLabelFormat()->set_ShowValue(true);
System::SharedPtr<IDataLabel> branch1Label = dataPoints->idx_get(0)->get_DataPointLevels()->idx_get(2)->get_Label();
branch1Label->get_DataLabelFormat()->set_ShowCategoryName(false);
branch1Label->get_DataLabelFormat()->set_ShowSeriesName(true);
branch1Label->get_DataLabelFormat()->get_TextFormat()->get_PortionFormat()->get_FillFormat()->set_FillType(Aspose::Slides::FillType::Solid);
branch1Label->get_DataLabelFormat()->get_TextFormat()->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Yellow());
System::SharedPtr<IFormat> steam4Format = dataPoints->idx_get(9)->get_DataPointLevels()->idx_get(1)->get_Format();
steam4Format->get_Fill()->set_FillType(Aspose::Slides::FillType::Solid);
steam4Format->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::FromArgb(255, 0, 176, 240));
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddColumnInTexBoxes_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 100, 100, 300, 300);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u"All these columns are limited to be within a single text container -- you can add or delete text and the new or remaining text automatically adjusts itself to flow within the container. You cannot have text flow from one container to other though -- we told you PowerPoint's column options for text are limited!");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
// Get text format of TextFrame
SharedPtr<ITextFrameFormat> format = txtFrame->get_TextFrameFormat();
// Specify number of columns in TextFrame
format->set_ColumnCount(3);
// Specify spacing between columns
format->set_ColumnSpacing ( 10);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ColumnsTest.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 100, 100, 300, 300);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u"All these columns are limited to be within a single text container -- you can add or delete text and the new or remaining text automatically adjusts itself to flow within the container. You cannot have text flow from one container to other though -- we told you PowerPoint's column options for text are limited!");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
// Get text format of TextFrame
SharedPtr<ITextFrameFormat> format = txtFrame->get_TextFrameFormat();
// Specify number of columns in TextFrame
format->set_ColumnCount(2);
//// Specify spacing between columns
//format->set_ColumnSpacing(10);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ErrorBarsCustomValues_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = sld->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Bubble, 0, 0, 500, 500,true);
// Adding custom Error chart and setting its format
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
SharedPtr<IErrorBarsFormat> errBarX = series->get_ErrorBarsXFormat();
SharedPtr<IErrorBarsFormat> errBarY = series->get_ErrorBarsYFormat();
errBarX->set_IsVisible(true);
errBarY->set_IsVisible(true);
errBarX->set_ValueType(ErrorBarValueType::Custom);
errBarY->set_ValueType(ErrorBarValueType::Custom);
// Accessing chart series data point and setting error bars values for individual point
SharedPtr<IChartDataPointCollection> points = series->get_DataPoints();
points->get_DataSourceTypeForErrorBarsCustomValues()->set_DataSourceTypeForXPlusValues(DataSourceType::DoubleLiterals);
points->get_DataSourceTypeForErrorBarsCustomValues()->set_DataSourceTypeForXMinusValues(DataSourceType::DoubleLiterals);
points->get_DataSourceTypeForErrorBarsCustomValues()->set_DataSourceTypeForYPlusValues (DataSourceType::DoubleLiterals);
points->get_DataSourceTypeForErrorBarsCustomValues()->set_DataSourceTypeForYMinusValues(DataSourceType::DoubleLiterals);
// Setting error bars for chart series points
for (int i = 0; i < points->get_Count(); i++)
{
points->idx_get(i)->get_ErrorBarsCustomValues()->get_XMinus()->set_AsLiteralDouble(i + 1);
points->idx_get(i)->get_ErrorBarsCustomValues()->get_XPlus()->set_AsLiteralDouble (i + 1);
points->idx_get(i)->get_ErrorBarsCustomValues()->get_YMinus()->set_AsLiteralDouble( i + 1);
points->idx_get(i)->get_ErrorBarsCustomValues()->get_YPlus()->set_AsLiteralDouble ( i + 1);
}
// Saving presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String templatePath = u"../templates/Presentation2.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
for (int x = 0; x < slide->get_Slide()->get_Shapes()->get_Count(); x++)
{
System::SharedPtr<IShape> shape = slide->get_Slide()->get_Shapes()->idx_get(x);
if (shape->get_Placeholder() != NULL) {
String text = u"";
if (shape->get_Placeholder()->get_Type() == PlaceholderType::CenteredTitle) // Whan text is empty, PowerPoint displays "Click to add title".
{
text = u"Click to add title";
}
else if (shape->get_Placeholder()->get_Type() == PlaceholderType::Subtitle) // do the same for subtitle.
{
text = u"Click to add subtitle";
}
System::Console::WriteLine(u"Placeholder : {0}", text);
}
}
pres->Save(u"../out/Placeholders_PromptText.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddDoughnutCallout_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Doughnut, 0, 0, 500, 500);
int seriesIndex = 0;
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();
// Delete default generated series and categories
chart->get_ChartData()->get_Series()->Clear();
chart->get_ChartData()->get_Categories()->Clear();
chart->set_HasLegend(false);
////////////
while (seriesIndex < 15)
{
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->Add(fact->GetCell(0, 0, seriesIndex + 1, ObjectExt::Box<System::String>(u"SERIES" + seriesIndex)), chart->get_Type());
series->set_Explosion(0);
series->get_ParentSeriesGroup()->set_DoughnutHoleSize (20);
series->get_ParentSeriesGroup()->set_FirstSliceAngle ( 351);
seriesIndex++;
}
int categoryIndex = 0;
while (categoryIndex < 15)
{
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(0, categoryIndex + 1, 0, ObjectExt::Box<System::String>(u"CATEGORY" + categoryIndex)));
int i = 0;
while (i < chart->get_ChartData()->get_Series()->get_Count())
{
SharedPtr<IChartSeries> iCS = chart->get_ChartData()->get_Series()->idx_get(i);
SharedPtr<IChartDataPoint> dataPoint = iCS->get_DataPoints()->AddDataPointForDoughnutSeries(fact->GetCell(0, categoryIndex + 1, i + 1, ObjectExt::Box<double>(1)));
dataPoint->get_Format()->get_Fill()->set_FillType (FillType::Solid);
dataPoint->get_Format()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid);
dataPoint->get_Format()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_White());
dataPoint->get_Format()->get_Line()->set_Width( 1);
dataPoint->get_Format()->get_Line()->set_Style (LineStyle::Single);
dataPoint->get_Format()->get_Line()->set_DashStyle(LineDashStyle::Solid);
if (i == chart->get_ChartData()->get_Series()->get_Count() - 1)
{
SharedPtr<IDataLabel> lbl = dataPoint->get_Label();
lbl->get_TextFormat()->get_TextBlockFormat()->set_AutofitType (TextAutofitType::Shape);
lbl->get_DataLabelFormat()->get_TextFormat()->get_PortionFormat()->set_FontBold (NullableBool::True);
lbl->get_DataLabelFormat()->get_TextFormat()->get_PortionFormat()->set_LatinFont(MakeObject<FontData>(u"DINPro-Bold"));
lbl->get_DataLabelFormat()->get_TextFormat()->get_PortionFormat()->set_FontHeight ( 12);
lbl->get_DataLabelFormat()->get_TextFormat()->get_PortionFormat()->get_FillFormat()->set_FillType (FillType::Solid);
lbl->get_DataLabelFormat()->get_TextFormat()->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color (System::Drawing::Color::get_LightGray());
lbl->get_DataLabelFormat()->get_Format()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_White());
lbl->get_DataLabelFormat()->set_ShowValue ( false);
lbl->get_DataLabelFormat()->set_ShowCategoryName ( true);
lbl->get_DataLabelFormat()->set_ShowSeriesName(false);
//lbl.DataLabelFormat.ShowLabelAsDataCallout = true;
lbl->get_DataLabelFormat()->set_ShowLeaderLines (true);
lbl->get_DataLabelFormat()->set_ShowLabelAsDataCallout ( false);
chart->ValidateChartLayout();
lbl->set_X((float)lbl->get_X() + (float)0.5);
lbl->set_Y((float)lbl->get_Y() + (float)0.5);
}
i++;
}
categoryIndex++;
}
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddEmbeddedFonts_out.pptx";
const String templatePath = u"../templates/EmbeddedFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
SharedPtr<IFontsManager> fontsManager = pres->get_FontsManager();
// get all embedded fonts
ArrayPtr<SharedPtr<IFontData>>embeddedFonts = fontsManager->GetEmbeddedFonts();
ArrayPtr<SharedPtr<IFontData>>allFonts = fontsManager->GetFonts();
auto enumerator_0 = allFonts->GetEnumerator();
decltype(enumerator_0->get_Current()) font = enumerator_0->get_Current();
while (enumerator_0->MoveNext() && (font = enumerator_0->get_Current(), true))
{
//if (font_0->get_FontName() == font->get_FontName())
if (embeddedFonts->Contains(font))
{
fontsManager->AddEmbeddedFont(font, EmbedFontCharacters::All);
}
}
// save the presentation without embedded "Calibri" font
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ErrorBars_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = sld->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Bubble, 0, 0, 500, 500, true);
// Adding custom Error chart and setting its format
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
SharedPtr<IErrorBarsFormat> errBarX = series->get_ErrorBarsXFormat();
SharedPtr<IErrorBarsFormat> errBarY = series->get_ErrorBarsYFormat();
errBarX->set_IsVisible(true);
errBarY->set_IsVisible(true);
errBarX->set_ValueType(ErrorBarValueType::Fixed);
errBarX->set_Value( 0.1f);
errBarY->set_ValueType(ErrorBarValueType::Percentage);
errBarX->set_Value(5);
errBarX->set_Type (ErrorBarType::Plus);
errBarY->get_Format()->get_Line()->set_Width(2);
errBarX->set_HasEndCap ( true);
// Saving presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/FunnelChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
System::SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Funnel, 50, 50, 500, 400);
chart->get_ChartData()->get_Categories()->Clear();
chart->get_ChartData()->get_Series()->Clear();
System::SharedPtr<IChartDataWorkbook> wb = chart->get_ChartData()->get_ChartDataWorkbook();
wb->Clear(0);
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A1", System::ObjectExt::Box<System::String>(u"Category 1")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A2", System::ObjectExt::Box<System::String>(u"Category 2")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A3", System::ObjectExt::Box<System::String>(u"Category 3")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A4", System::ObjectExt::Box<System::String>(u"Category 4")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A5", System::ObjectExt::Box<System::String>(u"Category 5")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A6", System::ObjectExt::Box<System::String>(u"Category 6")));
System::SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->Add(Aspose::Slides::Charts::ChartType::Funnel);
series->get_DataPoints()->AddDataPointForFunnelSeries(wb->GetCell(0, u"B1", System::ObjectExt::Box<int32_t>(50)));
series->get_DataPoints()->AddDataPointForFunnelSeries(wb->GetCell(0, u"B2", System::ObjectExt::Box<int32_t>(100)));
series->get_DataPoints()->AddDataPointForFunnelSeries(wb->GetCell(0, u"B3", System::ObjectExt::Box<int32_t>(200)));
series->get_DataPoints()->AddDataPointForFunnelSeries(wb->GetCell(0, u"B4", System::ObjectExt::Box<int32_t>(300)));
series->get_DataPoints()->AddDataPointForFunnelSeries(wb->GetCell(0, u"B5", System::ObjectExt::Box<int32_t>(400)));
series->get_DataPoints()->AddDataPointForFunnelSeries(wb->GetCell(0, u"B6", System::ObjectExt::Box<int32_t>(500)));
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/HistogramChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
System::SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Histogram, 50, 50, 500, 400);
chart->get_ChartData()->get_Categories()->Clear();
chart->get_ChartData()->get_Series()->Clear();
System::SharedPtr<IChartDataWorkbook> wb = chart->get_ChartData()->get_ChartDataWorkbook();
wb->Clear(0);
System::SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->Add(Aspose::Slides::Charts::ChartType::Histogram);
series->get_DataPoints()->AddDataPointForHistogramSeries(wb->GetCell(0, u"A1", System::ObjectExt::Box<int32_t>(15)));
series->get_DataPoints()->AddDataPointForHistogramSeries(wb->GetCell(0, u"A2", System::ObjectExt::Box<int32_t>(-41)));
series->get_DataPoints()->AddDataPointForHistogramSeries(wb->GetCell(0, u"A3", System::ObjectExt::Box<int32_t>(16)));
series->get_DataPoints()->AddDataPointForHistogramSeries(wb->GetCell(0, u"A4", System::ObjectExt::Box<int32_t>(10)));
series->get_DataPoints()->AddDataPointForHistogramSeries(wb->GetCell(0, u"A5", System::ObjectExt::Box<int32_t>(-23)));
series->get_DataPoints()->AddDataPointForHistogramSeries(wb->GetCell(0, u"A6", System::ObjectExt::Box<int32_t>(16)));
chart->get_Axes()->get_HorizontalAxis()->set_AggregationType(Aspose::Slides::Charts::AxisAggregationType::Automatic);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/HistogramParetoChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
System::SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Histogram, 50, 50, 500, 400);
chart->get_ChartData()->get_Series()->Add(Aspose::Slides::Charts::ChartType::ParetoLine);
chart->get_Axes()->get_SecondaryVerticalAxis()->set_NumberFormat(u"0%");
chart->get_Axes()->get_SecondaryVerticalAxis()->set_MaxValue(1);
chart->get_Axes()->get_SecondaryVerticalAxis()->set_IsAutomaticMaxValue(false);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
System::String svgPath = u"../templates/sample.svg";
System::String outPptxPath = u"../out/presentation.pptx";
auto p = System::MakeObject<Presentation>();
System::String svgContent = System::IO::File::ReadAllText(svgPath);
System::SharedPtr<ISvgImage> svgImage = System::MakeObject<SvgImage>(svgContent);
System::SharedPtr<IPPImage> ppImage = p->get_Images()->AddImage(svgImage);
p->get_Slides()->idx_get(0)->get_Shapes()->AddPictureFrame(Aspose::Slides::ShapeType::Rectangle, 0.0f, 0.0f, static_cast<float>(ppImage->get_Width()), static_cast<float>(ppImage->get_Height()), ppImage);
p->Save(outPptxPath, Aspose::Slides::Export::SaveFormat::Pptx);
System::String svgPath = u"../templates/sample.svg";
System::String outPptxPath = u"../out/presentation.pptx";
System::String baseDir = u"../templates/";
auto p = System::MakeObject<Presentation>();
System::String svgContent = System::IO::File::ReadAllText(System::MakeObject<System::Uri>(System::MakeObject<System::Uri>(baseDir), u"image1.svg")->get_AbsolutePath());
System::SharedPtr<ISvgImage> svgImage = System::MakeObject<SvgImage>(svgContent, System::MakeObject<ExternalResourceResolver>(), baseDir);
System::SharedPtr<IPPImage> ppImage = p->get_Images()->AddImage(svgImage);
p->get_Slides()->idx_get(0)->get_Shapes()->AddPictureFrame(Aspose::Slides::ShapeType::Rectangle, 0.0f, 0.0f, static_cast<float>(ppImage->get_Width()), static_cast<float>(ppImage->get_Height()), ppImage);
p->Save(outPptxPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/Image_In_TableCell_out.pptx";
const String ImagePath = u"../templates/Tulips.jpg";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> islide = pres->get_Slides()->idx_get(0);
// Define columns with widths and rows with heights
System::ArrayPtr<double> dblCols= System::MakeObject<System::Array<double>>(4,150 );
System::ArrayPtr<double> dblRows = System::MakeObject<System::Array<double>>(4,100 );
System::ArrayPtr<double> total_for_Cat = System::MakeObject<System::Array<double>>(5, 0);
// Add table shape to slide
auto tbl = islide->get_Shapes()->AddTable(50, 50, dblCols, dblRows);
// Get the picture
auto bitmap = MakeObject<System::Drawing::Bitmap>(ImagePath);
// Add image to presentation's images collection
SharedPtr<IPPImage> imgx = pres->get_Images()->AddImage(bitmap);
// Add image to first table cell
tbl->idx_get(0,0)->get_FillFormat()->set_FillType (FillType::Picture);
tbl->idx_get(0,0)->get_FillFormat()->get_PictureFillFormat()->set_PictureFillMode ( PictureFillMode::Stretch);
tbl->idx_get(0,0)->get_FillFormat()->get_PictureFillFormat()->get_Picture()->set_Image(imgx);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddCustomLines.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
SharedPtr<IChart> chart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddChart(ChartType::ClusteredColumn, 100, 100, 500, 400);
SharedPtr<IAutoShape> shape = chart->get_UserShapes()->get_Shapes()->AddAutoShape(ShapeType::Line, 0, chart->get_Height() / 2, chart->get_Width(), 0);
shape->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid);
shape->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Red());
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
void AddingEMZImagesToImageCollection()
{
// The path to the documents directory.
const String outPath = u"../out/AddingEMZImagesToImageCollection_out.pptx";
const String filePath = u"../templates/2.emz";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
auto data = GetFileByteData(filePath);
SharedPtr<IPPImage> imgx = pres->get_Images()->AddImage(data);
//Adding picture frame with EMZ image
auto m = slide->get_Shapes()->AddPictureFrame(ShapeType::Rectangle, 0, 0, pres->get_SlideSize()->get_Size().get_Width(), pres->get_SlideSize()->get_Size().get_Height(), imgx);
//Write the PPTX file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
}
ArrayPtr<uint8_t> GetFileByteData(System::String fileNameZip)
{
System::SharedPtr<System::IO::FileStream> fs = System::IO::File::OpenRead(fileNameZip);
System::ArrayPtr<uint8_t> buffer = System::MakeArray<uint8_t>(fs->get_Length(), 0);
fs->Read(buffer, 0, buffer->get_Length());
return buffer;
}
// The path to the documents directory.
const String outPath = u"../out/AddingSuperscriptAndSubscriptTextInTextFrame_out.pptx";
//const String templatePath = u"../templates/DefaultFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 100, 100, 300, 300);
// Add TextFrame to the Rectangle
SharedPtr<ITextFrame> tf = ashp->AddTextFrame(String::Empty);
tf->get_Paragraphs()->Clear();
// Adding the first Paragraph
SharedPtr<Paragraph> superPar = MakeObject<Paragraph>();
SharedPtr<Portion> portion1 = MakeObject<Portion>(u"SlideTitle");
superPar->get_Portions()->Add(portion1);
SharedPtr<Portion> superPortion = MakeObject<Portion>();
superPortion->get_PortionFormat()->set_Escapement(30);
superPortion->set_Text(u"TM");
superPar->get_Portions()->Add(superPortion);
// Adding the first Paragraph
SharedPtr<Paragraph> subPar = MakeObject<Paragraph>();
SharedPtr<Portion> portion2 = MakeObject<Portion>(u"a");
subPar->get_Portions()->Add(portion2);
SharedPtr<Portion> subPortion = MakeObject<Portion>();
subPortion->get_PortionFormat()->set_Escapement(-25);
subPortion->set_Text(u"i");
subPar->get_Portions()->Add(subPortion);
//Adding to text frame
ashp->get_TextFrame()->get_Paragraphs()->Add(superPar);
ashp->get_TextFrame()->get_Paragraphs()->Add(subPar);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/AddLayoutSlides.pptx";
// Instantiate Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Try to search by layout slide type
SharedPtr<IMasterLayoutSlideCollection> layoutSlides = pres->get_Masters()->idx_get(0)->get_LayoutSlides();
SharedPtr<ILayoutSlide> layoutSlide;
if (layoutSlides->GetByType(SlideLayoutType::TitleAndObject) != NULL)
{
layoutSlide = layoutSlides->GetByType(SlideLayoutType::TitleAndObject);
}
else if (layoutSlides->GetByType(SlideLayoutType::Title) != NULL)
{
layoutSlide = layoutSlides->GetByType(SlideLayoutType::Title);
}
if (layoutSlide == NULL)
{
// The situation when a presentation doesn't contain some type of layouts.
// presentation File only contains Blank and Custom layout types.
// But layout slides with Custom types has different slide names,
// like "Title", "Title and Content", etc. And it is possible to use these
// names for layout slide selection.
// Also it is possible to use the set of placeholder shape types. For example,
// Title slide should have only Title pleceholder type, etc.
for (int i = 0; i<layoutSlides->get_Count(); i++)
{
SharedPtr<ILayoutSlide> titleAndObjectLayoutSlide = layoutSlides->idx_get(i);
if (titleAndObjectLayoutSlide->get_Name().Equals(u"Title and Object"))
{
layoutSlide = titleAndObjectLayoutSlide;
break;
}
}
if (layoutSlide == NULL)
{
for (int i = 0; i < layoutSlides->get_Count(); i++)
{
SharedPtr<ILayoutSlide> titleLayoutSlide = layoutSlides->idx_get(i);
if (titleLayoutSlide->get_Name().Equals(u"Title"))
{
layoutSlide = titleLayoutSlide;
break;
}
}
if (layoutSlide == NULL)
{
layoutSlide = layoutSlides->GetByType(SlideLayoutType::Blank);
if (layoutSlide == NULL)
{
layoutSlide = layoutSlides->Add(SlideLayoutType::TitleAndObject, u"Title and Object");
}
}
}
}
// Adding empty slide with added layout slide
pres->get_Slides()->InsertEmptySlide(0, layoutSlide);
// Save the PPTX file to the Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddNodes_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::StackedList);
if (smart->get_AllNodes()->get_Count() > 0)
{
// Accessing SmartArt node at index 0
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArtNode> node = smart->get_AllNodes()->AddNode();
// Add Text
node->get_TextFrame()->set_Text(u"Test");
// SharedPtr<ISmartArtNodeCollection> nodeCollection = System::DynamicCast_noexcept<ISmartArtNodeCollection>(node->get_ChildNodes()); ;
auto nodeCollection = node->get_ChildNodes() ;
// Adding new child node at end of parent node
SharedPtr<ISmartArtNode> chNode = nodeCollection->AddNode();
// Add Text
chNode->get_TextFrame()->set_Text(u"Sample Text Added");
}
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddNodesSpecificPosition_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::StackedList);
if (smart->get_AllNodes()->get_Count() > 0)
{
// Accessing SmartArt node at index 0
System::SharedPtr<Aspose::Slides::SmartArt::SmartArtNode> node0 = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtNode>(smart->get_AllNodes()->idx_get(0));
// SharedPtr<ISmartArtNodeCollection> node0Collection = System::DynamicCast_noexcept<ISmartArtNodeCollection>(node0->get_ChildNodes()); ;
SharedPtr<ISmartArtNodeCollection> node0Collection = node0->get_ChildNodes() ;
// Adding new child node at position 2 in parent node
SharedPtr<ISmartArtNode> chNode = node0Collection->AddNodeByPosition(2);
// Add Text
chNode->get_TextFrame()->set_Text(u"Sample Text Added");
}
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddNotesSlideWithNotesStyle_out.pptx";
const String templatePath = u"../templates/AccessSlides.pptx";
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Accessing Master note slide
SharedPtr<IMasterNotesSlide> notesMaster = pres->get_MasterNotesSlideManager()->get_MasterNotesSlide();
if (notesMaster != NULL)
{
// Get MasterNotesSlide text style
SharedPtr<ITextStyle> notesStyle = notesMaster->get_NotesStyle();
//Set symbol bullet for the first level paragraphs
SharedPtr<IParagraphFormat> paragraphFormat = notesStyle->GetLevel(0);
paragraphFormat->get_Bullet()->set_Type(BulletType::Symbol);
}
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddOLEObjectFrame_out.pptx";
const String filePath = u"../templates/book1.xlsx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Save file to memory stream
{
System::SharedPtr<System::IO::Stream> fileStream = System::IO::File::OpenRead(filePath);
System::SharedPtr<System::IO::MemoryStream> MemStream = MakeObject< System::IO::MemoryStream>();
System::ArrayPtr<uint8_t> buffer = System::MakeObject<System::Array<uint8_t>>(4 * 1024, 0);
int32_t len;
while ((len = fileStream->Read(buffer, 0, buffer->get_Length())) > 0)
{
MemStream->Write(buffer, 0, len);
}
MemStream->set_Position(0);
// Add an Ole Object Frame shape
System::SharedPtr<IOleObjectFrame> oof = slide->get_Shapes()->AddOleObjectFrame(0, 0, 720, 540, u"Excel.Sheet.12", MemStream->ToArray());
}
//Write the PPTX file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>();
// Add comment
System::SharedPtr<ICommentAuthor> author1 = pres->get_CommentAuthors()->AddAuthor(u"Author_1", u"A.A.");
System::SharedPtr<IComment> comment1 = author1->get_Comments()->AddComment(u"comment1", pres->get_Slides()->idx_get(0), System::Drawing::PointF(10.0f, 10.0f), System::DateTime::get_Now());
// Add reply for comment1
System::SharedPtr<ICommentAuthor> author2 = pres->get_CommentAuthors()->AddAuthor(u"Autror_2", u"B.B.");
System::SharedPtr<IComment> reply1 = author2->get_Comments()->AddComment(u"reply 1 for comment 1", pres->get_Slides()->idx_get(0), System::Drawing::PointF(10.0f, 10.0f), System::DateTime::get_Now());
reply1->set_ParentComment(comment1);
// Add reply for comment1
System::SharedPtr<IComment> reply2 = author2->get_Comments()->AddComment(u"reply 2 for comment 1", pres->get_Slides()->idx_get(0), System::Drawing::PointF(10.0f, 10.0f), System::DateTime::get_Now());
reply2->set_ParentComment(comment1);
// Add reply to reply
System::SharedPtr<IComment> subReply = author1->get_Comments()->AddComment(u"subreply 3 for reply 2", pres->get_Slides()->idx_get(0), System::Drawing::PointF(10.0f, 10.0f), System::DateTime::get_Now());
subReply->set_ParentComment(reply2);
System::SharedPtr<IComment> comment2 = author2->get_Comments()->AddComment(u"comment 2", pres->get_Slides()->idx_get(0), System::Drawing::PointF(10.0f, 10.0f), System::DateTime::get_Now());
System::SharedPtr<IComment> comment3 = author2->get_Comments()->AddComment(u"comment 3", pres->get_Slides()->idx_get(0), System::Drawing::PointF(10.0f, 10.0f), System::DateTime::get_Now());
System::SharedPtr<IComment> reply3 = author1->get_Comments()->AddComment(u"reply 4 for comment 3", pres->get_Slides()->idx_get(0), System::Drawing::PointF(10.0f, 10.0f), System::DateTime::get_Now());
reply3->set_ParentComment(comment3);
// Display hierarchy on console
System::SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
auto comments = slide->GetSlideComments(nullptr);
for (int32_t i = 0; i < comments->get_Length(); i++)
{
System::SharedPtr<IComment> comment = comments[i];
while (comment->get_ParentComment() != nullptr)
{
System::Console::Write(u"\t");
comment = comment->get_ParentComment();
}
System::Console::Write(u"{0} : {1}", System::ObjectExt::Box<System::String>(comments[i]->get_Author()->get_Name()), System::ObjectExt::Box<System::String>(comments[i]->get_Text()));
System::Console::WriteLine();
}
pres->Save(u"../out/parent_comment.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
// Remove comment1 and all its replies
comment1->Remove();
pres->Save(u"../out/remove_comment.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
// 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);
// The path to the documents directory.
const String outPath = u"../out/AddRelativeScaleHeightPictureFrame_out.pptx";
const String filePath = u"../templates/Tulips.jpg";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Load Image to be added in presentaiton image collection
// Get the picture
auto bitmap = MakeObject<System::Drawing::Bitmap>(filePath);
// Add image to presentation's images collection
SharedPtr<IPPImage> imgx = pres->get_Images()->AddImage(bitmap);
// Add picture frame to slide
SharedPtr<IPictureFrame> pf = slide->get_Shapes()->AddPictureFrame(ShapeType::Rectangle, 50, 50, 100, 100, imgx);
// Setting relative scale width and height
pf->set_RelativeScaleHeight (0.8);
pf->set_RelativeScaleWidth(1.35);
//Write the PPTX file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddSimplePictureFrames_out.pptx";
const String filePath = u"../templates/Tulips.jpg";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Load Image to be added in presentaiton image collection
// Get the picture
auto bitmap = MakeObject<System::Drawing::Bitmap>(filePath);
// Add image to presentation's images collection
SharedPtr<IPPImage> imgx = pres->get_Images()->AddImage(bitmap);
// Add picture frame to slide
SharedPtr<IPictureFrame> pf = slide->get_Shapes()->AddPictureFrame(ShapeType::Rectangle, 50, 50, 100, 100, imgx);
//Write the PPTX file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
//Presentation path
const String outPath = u"../out/AddComments.pptx";
// Instantiate Presentation class
SharedPtr<Presentation>pres = MakeObject<Presentation>();
SharedPtr<ILayoutSlide>layout = pres->get_LayoutSlides()->idx_get(0);
pres->get_Slides()->AddEmptySlide(layout);
// Adding Author
SharedPtr<ICommentAuthor> author = pres->get_CommentAuthors()->AddAuthor(u"Mudassir", u"MF");
// Position of comments
System::Drawing::PointF point = System::Drawing::PointF(0.2f, 0.2f);
// Adding slide comment for an author on slide 1
author->get_Comments()->AddComment(u"Hello Mudassir, this is slide comment", pres->get_Slides()->idx_get(0), point, System::DateTime::get_Now());
// Adding slide comment for an author on slide 1
author->get_Comments()->AddComment(u"Hello Mudassir, this is second slide comment", pres->get_Slides()->idx_get(1), point, DateTime::get_Now());
// Accessing ISlide 1
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../templates/AddSlides.pptx";
// Instantiate Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Instantiate SlideCollection calss
SharedPtr<ISlideCollection> slds = pres->get_Slides();
for (int i = 0; i < pres->get_LayoutSlides()->get_Count(); i++)
{
// Add an empty slide to the Slides collection
slds->AddEmptySlide(pres->get_LayoutSlides()->idx_get(i));
}
// Save the PPTX file to the Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddStockChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::OpenHighLowClose, 0, 0, 500, 500);
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();
// Delete default generated series and categories
chart->get_ChartData()->get_Series()->Clear();
chart->get_ChartData()->get_Categories()->Clear();
// Add Catrgories
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 1, 0, ObjectExt::Box<System::String>(u"A")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 2, 0, ObjectExt::Box<System::String>(u"B")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 3, 0, ObjectExt::Box<System::String>(u"C")));
// Now, Adding a new series
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 1, ObjectExt::Box<System::String>(u"Open")), chart->get_Type());
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 2, ObjectExt::Box<System::String>(u"High")), chart->get_Type());
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 3, ObjectExt::Box<System::String>(u"Low")), chart->get_Type());
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 4, ObjectExt::Box<System::String>(u"Close")), chart->get_Type());
// Take first chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
// Now populating first series data
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 1, 1, ObjectExt::Box<double>(72)));
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 2, 1, ObjectExt::Box<double>(25)));
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 3, 1, ObjectExt::Box<double>(38)));
series = chart->get_ChartData()->get_Series()->idx_get(1);
// Now populating 2nd series data
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 1, 2, ObjectExt::Box<double>(172)));
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 2, 2, ObjectExt::Box<double>(57)));
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 3, 2, ObjectExt::Box<double>(57)));
series = chart->get_ChartData()->get_Series()->idx_get(2);
// Now populating 2nd series data
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 1, 3, ObjectExt::Box<double>(12)));
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 2, 3, ObjectExt::Box<double>(12)));
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 3, 3, ObjectExt::Box<double>(13)));
series = chart->get_ChartData()->get_Series()->idx_get(3);
// Now populating 2nd series data
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 1, 4, ObjectExt::Box<double>(25)));
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 2, 4, ObjectExt::Box<double>(38)));
series->get_DataPoints()->AddDataPointForStockSeries(fact->GetCell(defaultWorksheetIndex, 3, 4, ObjectExt::Box<double>(50)));
//Setting series group
chart->get_ChartData()->get_SeriesGroups()->idx_get(0)->get_UpDownBars()->set_HasUpDownBars (true);
chart->get_ChartData()->get_SeriesGroups()->idx_get(0)->get_HiLowLinesFormat()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid);
for(int i=0;i<chart->get_ChartData()->get_Series()->get_Count();i++)
{
series = chart->get_ChartData()->get_Series()->idx_get(i);
series->get_Format()->get_Line()->get_FillFormat()->set_FillType(FillType::NoFill);
}
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/SunburstChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
System::SharedPtr<IChart> chart=slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Sunburst, 50, 50, 500, 400);
chart->get_ChartData()->get_Categories()->Clear();
chart->get_ChartData()->get_Series()->Clear();
System::SharedPtr<IChartDataWorkbook> wb = chart->get_ChartData()->get_ChartDataWorkbook();
wb->Clear(0);
//branch 1
System::SharedPtr<IChartCategory> leaf = chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C1", System::ObjectExt::Box<System::String>(u"Leaf1")));
leaf->get_GroupingLevels()->SetGroupingItem(1, System::ObjectExt::Box<System::String>(u"Stem1"));
leaf->get_GroupingLevels()->SetGroupingItem(2, System::ObjectExt::Box<System::String>(u"Branch1"));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C2", System::ObjectExt::Box<System::String>(u"Leaf2")));
leaf = chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C3", System::ObjectExt::Box<System::String>(u"Leaf3")));
leaf->get_GroupingLevels()->SetGroupingItem(1, System::ObjectExt::Box<System::String>(u"Stem2"));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C4", System::ObjectExt::Box<System::String>(u"Leaf4")));
//branch 2
leaf = chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C5", System::ObjectExt::Box<System::String>(u"Leaf5")));
leaf->get_GroupingLevels()->SetGroupingItem(1, System::ObjectExt::Box<System::String>(u"Stem3"));
leaf->get_GroupingLevels()->SetGroupingItem(2, System::ObjectExt::Box<System::String>(u"Branch2"));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C6", System::ObjectExt::Box<System::String>(u"Leaf6")));
leaf = chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C7", System::ObjectExt::Box<System::String>(u"Leaf7")));
leaf->get_GroupingLevels()->SetGroupingItem(1, System::ObjectExt::Box<System::String>(u"Stem4"));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C8", System::ObjectExt::Box<System::String>(u"Leaf8")));
System::SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->Add(Aspose::Slides::Charts::ChartType::Sunburst);
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowCategoryName(true);
series->get_DataPoints()->AddDataPointForSunburstSeries(wb->GetCell(0, u"D1", System::ObjectExt::Box<int32_t>(4)));
series->get_DataPoints()->AddDataPointForSunburstSeries(wb->GetCell(0, u"D2", System::ObjectExt::Box<int32_t>(5)));
series->get_DataPoints()->AddDataPointForSunburstSeries(wb->GetCell(0, u"D3", System::ObjectExt::Box<int32_t>(3)));
series->get_DataPoints()->AddDataPointForSunburstSeries(wb->GetCell(0, u"D4", System::ObjectExt::Box<int32_t>(6)));
series->get_DataPoints()->AddDataPointForSunburstSeries(wb->GetCell(0, u"D5", System::ObjectExt::Box<int32_t>(9)));
series->get_DataPoints()->AddDataPointForSunburstSeries(wb->GetCell(0, u"D6", System::ObjectExt::Box<int32_t>(9)));
series->get_DataPoints()->AddDataPointForSunburstSeries(wb->GetCell(0, u"D7", System::ObjectExt::Box<int32_t>(4)));
series->get_DataPoints()->AddDataPointForSunburstSeries(wb->GetCell(0, u"D8", System::ObjectExt::Box<int32_t>(3)));
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/TreemapChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
System::SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Treemap, 50, 50, 500, 400);
chart->get_ChartData()->get_Categories()->Clear();
chart->get_ChartData()->get_Series()->Clear();
System::SharedPtr<IChartDataWorkbook> wb = chart->get_ChartData()->get_ChartDataWorkbook();
wb->Clear(0);
//branch 1
System::SharedPtr<IChartCategory> leaf = chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C1", System::ObjectExt::Box<System::String>(u"Leaf1")));
leaf->get_GroupingLevels()->SetGroupingItem(1, System::ObjectExt::Box<System::String>(u"Stem1"));
leaf->get_GroupingLevels()->SetGroupingItem(2, System::ObjectExt::Box<System::String>(u"Branch1"));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C2", System::ObjectExt::Box<System::String>(u"Leaf2")));
leaf = chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C3", System::ObjectExt::Box<System::String>(u"Leaf3")));
leaf->get_GroupingLevels()->SetGroupingItem(1, System::ObjectExt::Box<System::String>(u"Stem2"));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C4", System::ObjectExt::Box<System::String>(u"Leaf4")));
//branch 2
leaf = chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C5", System::ObjectExt::Box<System::String>(u"Leaf5")));
leaf->get_GroupingLevels()->SetGroupingItem(1, System::ObjectExt::Box<System::String>(u"Stem3"));
leaf->get_GroupingLevels()->SetGroupingItem(2, System::ObjectExt::Box<System::String>(u"Branch2"));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C6", System::ObjectExt::Box<System::String>(u"Leaf6")));
leaf = chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C7", System::ObjectExt::Box<System::String>(u"Leaf7")));
leaf->get_GroupingLevels()->SetGroupingItem(1, System::ObjectExt::Box<System::String>(u"Stem4"));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"C8", System::ObjectExt::Box<System::String>(u"Leaf8")));
System::SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->Add(Aspose::Slides::Charts::ChartType::Treemap);
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowCategoryName(true);
series->get_DataPoints()->AddDataPointForTreemapSeries(wb->GetCell(0, u"D1", System::ObjectExt::Box<int32_t>(4)));
series->get_DataPoints()->AddDataPointForTreemapSeries(wb->GetCell(0, u"D2", System::ObjectExt::Box<int32_t>(5)));
series->get_DataPoints()->AddDataPointForTreemapSeries(wb->GetCell(0, u"D3", System::ObjectExt::Box<int32_t>(3)));
series->get_DataPoints()->AddDataPointForTreemapSeries(wb->GetCell(0, u"D4", System::ObjectExt::Box<int32_t>(6)));
series->get_DataPoints()->AddDataPointForTreemapSeries(wb->GetCell(0, u"D5", System::ObjectExt::Box<int32_t>(9)));
series->get_DataPoints()->AddDataPointForTreemapSeries(wb->GetCell(0, u"D6", System::ObjectExt::Box<int32_t>(9)));
series->get_DataPoints()->AddDataPointForTreemapSeries(wb->GetCell(0, u"D7", System::ObjectExt::Box<int32_t>(4)));
series->get_DataPoints()->AddDataPointForTreemapSeries(wb->GetCell(0, u"D8", System::ObjectExt::Box<int32_t>(3)));
series->set_ParentLabelLayout(Aspose::Slides::Charts::ParentLabelLayoutType::Overlapping);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddVBAMacros_out.pptm";
// Load the desired the presentation
SharedPtr<Presentation> presentation = MakeObject<Presentation>();
// Create new VBA Project
presentation->set_VbaProject(MakeObject<VbaProject>());
// Add empty module to the VBA project
SharedPtr<IVbaModule> module = presentation->get_VbaProject()->get_Modules()->AddEmptyModule(u"Module");
// Set module source code
module->set_SourceCode(u"Sub Test(oShape As Shape) MsgBox \"Test\" End Sub");
// Create reference to <stdole>
SharedPtr<VbaReferenceOleTypeLib> stdoleReference =
MakeObject<VbaReferenceOleTypeLib>(u"stdole", u"*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\\Windows\\system32\\stdole2.tlb#OLE Automation");
// Create reference to Office
SharedPtr<VbaReferenceOleTypeLib> officeReference =
MakeObject<VbaReferenceOleTypeLib>(u"Office", u"*\\G{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.0#0#C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE14\\MSO.DLL#Microsoft Office 14.0 Object Library");
// Add references to the VBA project
presentation->get_VbaProject()->get_References()->Add(stdoleReference);
presentation->get_VbaProject()->get_References()->Add(officeReference);
// Save PPTX to Disk
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptm);
// The path to the documents directory.
const String outPath = u"../out/AddVideoFrame_out.pptx";
const String filePath = u"../templates/Wildlife.mp4";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Load the wav sound file to stream
System::SharedPtr<System::IO::FileStream> stream = System::MakeObject<System::IO::FileStream>(filePath, System::IO::FileMode::Open, System::IO::FileAccess::Read);
// Add Video Frame
System::SharedPtr<IVideoFrame> vf = slide->get_Shapes()->AddVideoFrame(50, 150, 300, 150, filePath);
// Set Play Mode and Volume of the Video
vf->set_PlayMode (VideoPlayModePreset::Auto);
vf->set_Volume ( AudioVolumeMode::Loud);
//Write the PPTX file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AddVideoFrameFromWebSource_out.pptx";
const String filePath = u"../templates/video1.avi";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add Video Frame from web source
System::SharedPtr<IVideoFrame> vf = slide->get_Shapes()->AddVideoFrame(10, 10, 427, 240,u"https://www.youtube.com/embed/Tj75Arhq5ho");
// Set Play Mode and Volume of the Video
vf->set_PlayMode(VideoPlayModePreset::Auto);
//Write the PPTX file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/WaterfallChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
System::SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Waterfall, 50, 50, 500, 400);
chart->get_ChartData()->get_Categories()->Clear();
chart->get_ChartData()->get_Series()->Clear();
System::SharedPtr<IChartDataWorkbook> wb = chart->get_ChartData()->get_ChartDataWorkbook();
wb->Clear(0);
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A1", System::ObjectExt::Box<System::String>(u"Category 1")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A2", System::ObjectExt::Box<System::String>(u"Category 2")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A3", System::ObjectExt::Box<System::String>(u"Category 3")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A4", System::ObjectExt::Box<System::String>(u"Category 4")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A5", System::ObjectExt::Box<System::String>(u"Category 5")));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A6", System::ObjectExt::Box<System::String>(u"Category 6")));
System::SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->Add(Aspose::Slides::Charts::ChartType::Waterfall);
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true);
series->get_DataPoints()->AddDataPointForWaterfallSeries(wb->GetCell(0, u"B1", System::ObjectExt::Box<int32_t>(15)));
series->get_DataPoints()->AddDataPointForWaterfallSeries(wb->GetCell(0, u"B2", System::ObjectExt::Box<int32_t>(-41)));
series->get_DataPoints()->AddDataPointForWaterfallSeries(wb->GetCell(0, u"B3", System::ObjectExt::Box<int32_t>(16)));
series->get_DataPoints()->AddDataPointForWaterfallSeries(wb->GetCell(0, u"B4", System::ObjectExt::Box<int32_t>(10)));
series->get_DataPoints()->AddDataPointForWaterfallSeries(wb->GetCell(0, u"B5", System::ObjectExt::Box<int32_t>(-23)));
series->get_DataPoints()->AddDataPointForWaterfallSeries(wb->GetCell(0, u"B6", System::ObjectExt::Box<int32_t>(16)));
series->get_DataPoints()->idx_get(5)->set_SetAsTotal(true);
series->set_ShowConnectorLines(false);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/ExistingChart.pptx";
const String outPath = u"../out/AnimatingCategoriesElements_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
auto chart = DynamicCast<Aspose::Slides::Charts::Chart>(slide->get_Shapes()->idx_get(0));
// Animate categories' elements
slide->get_Timeline()->get_MainSequence()->AddEffect(chart, EffectType::Fade, EffectSubtype::None, EffectTriggerType::AfterPrevious);
auto sequence = DynamicCast<Aspose::Slides::Animation::Sequence>(slide->get_Timeline()->get_MainSequence());
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 0, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 1, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 2, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 2, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType:: ByElementInCategory, 2, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInCategory, 2, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/ExistingChart.pptx";
const String outPath = u"../out/AnimatingSeries.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
auto chart = DynamicCast<Aspose::Slides::Charts::Chart>(slide->get_Shapes()->idx_get(0));
// Animate series
slide->get_Timeline()->get_MainSequence()->AddEffect(chart, EffectType::Fade, EffectSubtype::None, EffectTriggerType::AfterPrevious);
auto sequence = DynamicCast<Aspose::Slides::Animation::Sequence>(slide->get_Timeline()->get_MainSequence());
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 0,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 1,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 2,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart,EffectChartMajorGroupingType::BySeries, 3,EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/ExistingChart.pptx";
const String outPath = u"../out/AnimatingSeriesElements.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
auto chart = DynamicCast<Aspose::Slides::Charts::Chart>(slide->get_Shapes()->idx_get(0));
// Animate series elements
slide->get_Timeline()->get_MainSequence()->AddEffect(chart, EffectType::Fade, EffectSubtype::None, EffectTriggerType::AfterPrevious);
auto sequence = DynamicCast<Aspose::Slides::Animation::Sequence>(slide->get_Timeline()->get_MainSequence());
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 0, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 1, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 2, 0, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 2, 1, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 2, 2, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
sequence->AddEffect(chart, EffectChartMinorGroupingType::ByElementInSeries, 2, 3, EffectType::Appear, EffectSubtype::None, EffectTriggerType::AfterPrevious);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String templatePath = u"../templates/Presentation1.pptx";
const String outPath = u"../out/animationEffectinParagraph.pptx";
auto presentation = System::MakeObject<Presentation>(templatePath);
// select paragraph to add effect
auto autoShape = System::DynamicCast<Aspose::Slides::IAutoShape>(presentation->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));
auto paragraph = autoShape->get_TextFrame()->get_Paragraphs()->idx_get(0);
// add Fly animation effect to selected paragraph
auto effect = presentation->get_Slides()->idx_get(0)->get_Timeline()->get_MainSequence()->AddEffect(
paragraph,
Aspose::Slides::Animation::EffectType::Fly,
Aspose::Slides::Animation::EffectSubtype::Left,
Aspose::Slides::Animation::EffectTriggerType::OnClick);
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AnimationsOnOLEObject_out.pptx";
const String templatePath = u"../templates/AccessingOLEObjectFrame.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
//Accessing OLE Object
System::SharedPtr<IOleObjectFrame> ole = System::DynamicCast<Aspose::Slides::IOleObjectFrame>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));
//Applying animation effects
System::SharedPtr<IEffect> effect = pres->get_Slides()->idx_get(0)->get_Timeline()->get_MainSequence()->AddEffect(ole, Aspose::Slides::Animation::EffectType::OLEObjectOpen, Aspose::Slides::Animation::EffectSubtype::None, Aspose::Slides::Animation::EffectTriggerType::OnClick);
//System::SharedPtr<IEffect> effect = pres->get_Slides()->idx_get(0)->get_Timeline()->get_MainSequence()->AddEffect(ole, Aspose::Slides::Animation::EffectType::OLEObjectEdit, Aspose::Slides::Animation::EffectSubtype::None, Aspose::Slides::Animation::EffectTriggerType::OnClick);
//System::SharedPtr<IEffect> effect = pres->get_Slides()->idx_get(0)->get_Timeline()->get_MainSequence()->AddEffect(ole, Aspose::Slides::Animation::EffectType::OLEObjectShow, Aspose::Slides::Animation::EffectSubtype::None, Aspose::Slides::Animation::EffectTriggerType::OnClick);
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
//Now loading the presentaiton with effects
System::SharedPtr<Presentation> pres2 = System::MakeObject<Presentation>(outPath);
System::SharedPtr<IShape> shape = pres2->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0);
System::ArrayPtr<System::SharedPtr<IEffect>> effects = pres2->get_Slides()->idx_get(0)->get_Timeline()->get_MainSequence()->GetEffectsByShape(shape);
if (effects->get_Length() > 0 && effects[0]->get_PresetClassType() == Aspose::Slides::Animation::EffectPresetClassType::OLEActionVerbs)
System::Console::WriteLine(u"This shape has the OLE Action Verb effect");
// The path to the documents directory.
const String outPath = u"../out/AnimationsOnShapes_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Now create effect "PathFootball" for existing shape from scratch.
SharedPtr<IAutoShape> ashp = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 150, 250, 25);
ashp->AddTextFrame(u"Animated TextBox");
// Add PathFootBall animation effect
slide->get_Timeline()->get_MainSequence()->AddEffect(ashp, EffectType::PathFootball,
EffectSubtype::None, EffectTriggerType::AfterPrevious);
// Create some kind of "button".
SharedPtr<IAutoShape> shapeTrigger = slide->get_Shapes()->AddAutoShape(ShapeType::Bevel, 10, 10, 20, 20);
// Create sequence of effects for this button.
SharedPtr<ISequence> seqInter = slide->get_Timeline()->get_InteractiveSequences()->Add(shapeTrigger);
// Create custom user path. Our object will be moved only after "button" click.
SharedPtr<IEffect> fxUserPath = seqInter->AddEffect(ashp, EffectType::PathUser, EffectSubtype::None, EffectTriggerType::OnClick);
// Created path is empty so we should add commands for moving.
SharedPtr<MotionEffect> motionBhv = DynamicCast<MotionEffect>(fxUserPath->get_Behaviors()->idx_get(0));
// SharedPtr<PointF> point = MakeObject<PointF >(0.076, 0.59);
const PointF point = PointF (0.076, 0.59);
System::ArrayPtr<PointF> pts = System::MakeObject<System::Array<PointF>>(1, point);
motionBhv->get_Path()->Add(MotionCommandPathType::LineTo, pts, MotionPathPointsType::Auto, true);
//PointF point2[1] = { -0.076, -0.59 };
const PointF point2 = PointF(-0.076, -0.59 );
System::ArrayPtr<PointF> pts2 = System::MakeObject<System::Array<PointF>>(1, point2);
motionBhv->get_Path()->Add(MotionCommandPathType::LineTo, pts2, MotionPathPointsType::Auto, false);
motionBhv->get_Path()->Add(MotionCommandPathType::End, nullptr, MotionPathPointsType::Auto, false);
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/Apply3DRotationEffectOnShape_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Now create effect "PathFootball" for existing shape from scratch.
SharedPtr<IAutoShape> autoShape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 30, 30, 200, 200);
autoShape->get_ThreeDFormat()->set_Depth (6);
autoShape->get_ThreeDFormat()->get_Camera()->SetRotation(40, 35, 20);
autoShape->get_ThreeDFormat()->get_Camera()->set_CameraType(CameraPresetType::IsometricLeftUp);
autoShape->get_ThreeDFormat()->get_LightRig()->set_LightType ( LightRigPresetType::Balanced);
autoShape = slide->get_Shapes()->AddAutoShape(ShapeType::Line, 30, 300, 200, 200);
autoShape->get_ThreeDFormat()->set_Depth(6);
autoShape->get_ThreeDFormat()->get_Camera()->SetRotation(0, 35, 20);
autoShape->get_ThreeDFormat()->get_Camera()->set_CameraType(CameraPresetType::IsometricLeftUp);
autoShape->get_ThreeDFormat()->get_LightRig()->set_LightType(LightRigPresetType::Balanced);
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ApplyBevelEffects_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Now create effect "PathFootball" for existing shape from scratch.
SharedPtr<IAutoShape> autoShape = slide->get_Shapes()->AddAutoShape(ShapeType::Ellipse, 30, 30, 100, 100);
autoShape->get_FillFormat()->set_FillType ( FillType::Solid);
autoShape->get_FillFormat()->get_SolidFillColor()->set_Color ( Color::get_Green());
SharedPtr<ILineFillFormat> format = autoShape->get_LineFormat()->get_FillFormat();
format->set_FillType ( FillType::Solid);
format->get_SolidFillColor()->set_Color(Color::get_Orange());
autoShape->get_LineFormat()->set_Width ( 2.0);
// Set ThreeDFormat properties of shape
autoShape->get_ThreeDFormat()->set_Depth(4);
autoShape->get_ThreeDFormat()->get_BevelTop()->set_BevelType (BevelPresetType::Circle);
autoShape->get_ThreeDFormat()->get_BevelTop()->set_Height ( 6);
autoShape->get_ThreeDFormat()->get_BevelTop()->set_Width ( 6);
autoShape->get_ThreeDFormat()->get_Camera()->set_CameraType(CameraPresetType::OrthographicFront);
autoShape->get_ThreeDFormat()->get_LightRig()->set_LightType(LightRigPresetType::ThreePt);
autoShape->get_ThreeDFormat()->get_LightRig()->set_Direction(LightingDirection::Top);
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String templatePath = u"../templates/HelloWorld.pptx";
const String templateThemePath = u"../templates/Theme1Word.pptx";
const String outPptxFileName = u"../out/ApplyingExternalThemeToDependingSlides_out.ppt";
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
pres->get_Masters()->idx_get(0)->ApplyExternalThemeToDependingSlides(templateThemePath);
pres->Save(outPptxFileName, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ApplyInnerShadow_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u" ");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
// Create the Paragraph object for text frame
SharedPtr<IParagraph> paragraph = txtFrame->get_Paragraphs()->idx_get(0);
// Create Portion object for paragraph
SharedPtr<IPortion> portion = paragraph->get_Portions()->idx_get(0);
portion->set_Text(u"Aspose TextBox");
portion->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
portion->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
portion->get_PortionFormat()->set_FontHeight(50);
SharedPtr<IPortionFormat> pf = portion->get_PortionFormat();
// Enable InnerShadowEffect
SharedPtr<IEffectFormat> ef = pf->get_EffectFormat();
ef->EnableInnerShadowEffect();
// Set all necessary parameters
ef->get_InnerShadowEffect()->set_BlurRadius ( 8.0);
ef->get_InnerShadowEffect()->set_Direction(90.0);
ef->get_InnerShadowEffect()->set_Distance ( 6.0);
ef->get_InnerShadowEffect()->get_ShadowColor()->set_B (189);
// Set ColorType as Scheme
ef->get_InnerShadowEffect()->get_ShadowColor()->set_ColorType (ColorType::Scheme);
// Set Scheme Color
ef->get_InnerShadowEffect()->get_ShadowColor()->set_SchemeColor ( SchemeColor::Accent1);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ApplyOuterShadow_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u" ");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
// Create the Paragraph object for text frame
SharedPtr<IParagraph> paragraph = txtFrame->get_Paragraphs()->idx_get(0);
// Create Portion object for paragraph
SharedPtr<IPortion> portion = paragraph->get_Portions()->idx_get(0);
portion->set_Text(u"Aspose TextBox");
portion->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
portion->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
portion->get_PortionFormat()->set_FontHeight(50);
SharedPtr<IPortionFormat> pf = portion->get_PortionFormat();
// Enable InnerShadowEffect
SharedPtr<IEffectFormat> ef = pf->get_EffectFormat();
ef->EnableOuterShadowEffect();
// Set all necessary parameters
ef->get_OuterShadowEffect()->set_BlurRadius(6.0);
ef->get_OuterShadowEffect()->set_Direction(123.0);
ef->get_OuterShadowEffect()->set_Distance(5.0);
ef->get_OuterShadowEffect()->get_ShadowColor()->set_G(200);
// Set ColorType as Scheme
ef->get_OuterShadowEffect()->get_ShadowColor()->set_ColorType(ColorType::Scheme);
// Set Scheme Color
ef->get_OuterShadowEffect()->get_ShadowColor()->set_SchemeColor(SchemeColor::Dark1);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/RectPicFrame.pptx";
const String outPath = u"../out/ProtectedSample.pptx";
//Instatiate Presentation class that represents a PPTX
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//ISlide object for accessing the slides in the presentation
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
//IShape object for holding temporary shapes
SharedPtr<IShape> shape;
//Traversing through all the slides in the presentation
for (int slideCount = 0; slideCount < pres->get_Slides()->get_Count(); slideCount++)
{
slide = pres->get_Slides()->idx_get(slideCount);
//Travesing through all the shapes in the slides
for (int count = 0; count < slide->get_Shapes()->get_Count(); count++)
{
shape = slide->get_Shapes()->idx_get(count);
if (System::ObjectExt::Is<IAutoShape>(shape)) {
//Type casting to Auto shape and getting auto shape lock
SharedPtr<IAutoShape> aShp = DynamicCast<Aspose::Slides::IAutoShape>(shape);
SharedPtr<IAutoShapeLock> autoShapeLock = DynamicCast<Aspose::Slides::IAutoShapeLock>(aShp->get_ShapeLock());
//Applying shapes locks
autoShapeLock->set_PositionLocked(true);
autoShapeLock->set_SelectLocked(true);
autoShapeLock->set_SizeLocked(true);
}
//if shape is group shape
else if (System::ObjectExt::Is<IGroupShape>(shape)) {
//Type casting to group shape and getting group shape lock
SharedPtr<IGroupShape> group = DynamicCast<Aspose::Slides::IGroupShape>(shape);
SharedPtr<IGroupShapeLock> groupShapeLock = DynamicCast<Aspose::Slides::IGroupShapeLock>(group->get_ShapeLock());
//Applying shapes locks
groupShapeLock->set_GroupingLocked(true);
groupShapeLock->set_PositionLocked(true);
groupShapeLock->set_SelectLocked(true);
groupShapeLock->set_SizeLocked(true);
}
//if shape is a connector
else if (System::ObjectExt::Is<IConnector>(shape)) {
//Type casting to connector shape and getting connector shape lock
SharedPtr<IConnector> conn = DynamicCast<Aspose::Slides::IConnector>(shape);
SharedPtr<IConnectorLock> connLock = DynamicCast<Aspose::Slides::IConnectorLock>(conn->get_ShapeLock());
//Applying shapes locks
connLock->set_PositionMove(true);
connLock->set_SelectLocked(true);
connLock->set_SizeLocked(true);
}
//if shape is picture frame
else if (System::ObjectExt::Is<IPictureFrame>(shape)) {
//Type casting to pitcture frame shape and getting picture frame shape lock
SharedPtr<IPictureFrame> pic = DynamicCast<Aspose::Slides::IPictureFrame>(shape);
SharedPtr<IPictureFrameLock> picLock = DynamicCast<Aspose::Slides::IPictureFrameLock>(pic->get_ShapeLock());
//Applying shapes locks
picLock->set_PositionLocked(true);
picLock->set_SelectLocked(true);
picLock->set_SizeLocked(true);
}
}
}
//Saving the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AssistantNode.pptx";
const String outPath = u"../out/ChangeAssitantNode_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Traverse through every shape inside first slide
for (int x = 0; x < pres->get_Slides()->idx_get(0)->get_Shapes()->get_Count(); x++)
{
SharedPtr<IShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(x);
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape))
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArt> smart = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArt>(shape);
for (int i = 0; i < smart->get_AllNodes()->get_Count(); i++)
{
// Accessing SmartArt node at index i
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArtNode> node = smart->get_AllNodes()->idx_get(i);
if (node->get_IsAssistant())
{
// Setting Assitant node to false and making it normal node
node->set_IsAssistant(false);
}
}
}
}
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AutomaticChartSeriescolor.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
// Set first series to Show Values
chart->get_ChartData()->get_Series()->idx_get(0)->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true);
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();
// Delete default generated series and categories
chart->get_ChartData()->get_Series()->Clear();
chart->get_ChartData()->get_Categories()->Clear();
int seriesCount = chart->get_ChartData()->get_Series()->get_Count();
int catCount = chart->get_ChartData()->get_Categories()->get_Count();
// Adding new series
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 1, ObjectExt::Box<String>(u"Series 1")), chart->get_Type());
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 2, ObjectExt::Box<String>(u"Series 2")), chart->get_Type());
// Adding new categories
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 1, 0, ObjectExt::Box<String>(u"Caetegoty 1")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 2, 0, ObjectExt::Box<String>(u"Caetegoty 2")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 3, 0, ObjectExt::Box<String>(u"Caetegoty 3")));
// Take first chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
// Now populating series data
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 1, ObjectExt::Box<double>(20)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 1, ObjectExt::Box<double>(50)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 1, ObjectExt::Box<double>(30)));
// Setting automatic fill color for series
series->get_Format()->get_Fill()->set_FillType(FillType::NotDefined);
// Take second chart series
series = chart->get_ChartData()->get_Series()->idx_get(1);
// Now populating series data
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 2, ObjectExt::Box<double>(30)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 2, ObjectExt::Box<double>(10)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 2, ObjectExt::Box<double>(60)));
// Setting fill color for series
series->get_Format()->get_Fill()->set_FillType(FillType::Solid);
series->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Gray());
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/BestImagesCompressionRatio_out.pdf";
const String templatePath = u"../templates/AccessSlides.pptx";
System::SharedPtr<PdfOptions> options = System::MakeObject<PdfOptions>();
options->set_BestImagesCompressionRatio(true);
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pdf, options);
// The path to the documents directory.
const String outPath = u"../out/CellSplit_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> islide = pres->get_Slides()->idx_get(0);
// Define columns with widths and rows with heights
System::ArrayPtr<double> dblCols = System::MakeObject<System::Array<double>>(4, 70);
System::ArrayPtr<double> dblRows = System::MakeObject<System::Array<double>>(4, 70);
// Add table shape to slide
SharedPtr<ITable> table = islide->get_Shapes()->AddTable(100, 50, dblCols, dblRows);
// Set border format for each cell
for (int x = 0; x < table->get_Rows()->get_Count(); x++)
{
SharedPtr<IRow> row = table->get_Rows()->idx_get(x);
for(int y = 0; y < row->get_Count(); y++)
{
SharedPtr<ICell> cell = row->idx_get(y);
cell->get_BorderTop()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderTop()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderTop()->set_Width( 5);
cell->get_BorderBottom()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderBottom()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderBottom()->set_Width(5);
cell->get_BorderLeft()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderLeft()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderLeft()->set_Width(5);
cell->get_BorderRight()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderRight()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderRight()->set_Width(5);
}
}
// Merging cells (1, 1) x (2, 1)
table->MergeCells(table->idx_get(1, 1), table->idx_get(2, 1), false);
// Merging cells (1, 2) x (2, 2)
table->MergeCells(table->idx_get(1, 2), table->idx_get(2, 2), false);
// split cell (1, 1).
table->idx_get(1, 1)->SplitByWidth(table->idx_get(2, 1)->get_Width() / 2);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/ExistingChart.pptx";
const String outPath = u"../out/ChangeChartCategoryAxis_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<Chart> chart = DynamicCast<Aspose::Slides::Charts::Chart>(slide->get_Shapes()->idx_get(0));
chart->get_Axes()->get_HorizontalAxis()->set_CategoryAxisType(CategoryAxisType::Date);
chart->get_Axes()->get_HorizontalAxis()->set_IsAutomaticMajorUnit( false);
chart->get_Axes()->get_HorizontalAxis()->set_MajorUnit ( 1);
chart->get_Axes()->get_HorizontalAxis()->set_MajorUnitScale (TimeUnitType::Months);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ChangeColorOfCategoriesInSeries_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
// Take chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
//Accessing point
SharedPtr<IChartDataPoint> point = series->get_DataPoints()->idx_get(0);
point->get_Format()->get_Fill()->set_FillType(FillType::Solid);
point->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Blue());
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ChangeOLEObjectData_out.xlsx";
const String templatePath = u"../templates/AccessingOLEObjectFrame.pptx";
// Load the desired the presentation
System::SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Cast the shape to OleObjectFrame
SharedPtr<OleObjectFrame> oof = DynamicCast<Aspose::Slides::OleObjectFrame>(slide->get_Shapes()->idx_get(0));
// Read the OLE Object and write it to disk
if (oof != NULL)
{
/*
System::ArrayPtr<uint8_t> buffer = oof->get_ObjectData();
{
// System::SharedPtr<System::IO::FileStream> stream = System::MakeObject<System::IO::FileStream>(outPath, System::IO::FileMode::Create, System::IO::FileAccess::Write, System::IO::FileShare::Read);
System::SharedPtr<System::IO::MemoryStream> stream = System::MakeObject<System::IO::MemoryStream>(buffer);
stream->set_Position(0);
stream->Flush();
stream->Close();
// Reading object data in Workbook
//Read input excel file
boost::intrusive_ptr<Aspose::Cells::IWorkbook> workbook = Aspose::Cells::Factory::CreateIWorkbook("stream");
//Accessing the first worksheet in the Excel file
boost::intrusive_ptr<Aspose::Cells::IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0);
//Get cells from sheet
intrusive_ptr<Aspose::Cells::ICells> cells = worksheet->GetICells();
using (System.IO.MemoryStream msln = new System.IO.MemoryStream(ole.ObjectData))
{
Wb = new Aspose.Cells.Workbook(msln);
using (System.IO.MemoryStream msout = new System.IO.MemoryStream())
{
// Modifying the workbook data
Wb.Worksheets[0].Cells[0, 4].PutValue("E");
Wb.Worksheets[0].Cells[1, 4].PutValue(12);
Wb.Worksheets[0].Cells[2, 4].PutValue(14);
Wb.Worksheets[0].Cells[3, 4].PutValue(15);
Aspose.Cells.OoxmlSaveOptions so1 = new Aspose.Cells.OoxmlSaveOptions(Aspose.Cells.SaveFormat.Xlsx);
Wb.Save(msout, so1);
// Changing Ole frame object data
msout.Position = 0;
ole.ObjectData = msout.ToArray();
}
}
}*/
}
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/ChangeSlidePosition.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Accessing Slide by ID from collection
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Set the new position for the slide
slide->set_SlideNumber(2);
// Writing the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ChangeShapeOrder_out.pptx";
const String templatePath = u"../templates/HelloWorld.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
ashp->get_FillFormat()->set_FillType(FillType::NoFill);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u" ");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
// Create the Paragraph object for text frame
SharedPtr<IParagraph> paragraph = txtFrame->get_Paragraphs()->idx_get(0);
// Create Portion object for paragraph
SharedPtr<IPortion> portion = paragraph->get_Portions()->idx_get(0);
portion->set_Text(u"Watermark Text Watermark Text Watermark Text");
//Adding another shape
SharedPtr<IAutoShape> ashape2 = slide->get_Shapes()->AddAutoShape(ShapeType::Triangle, 200, 365, 400, 150);
//Reorder shape
slide->get_Shapes()->Reorder(2, ashape2);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ChangeSmartArtLayout_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::BasicBlockList);
// Change LayoutType to BasicProcess
smart->set_Layout(SmartArtLayoutType::BasicProcess);
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/SmartArt.pptx";
const String outPath = u"../out/ChangeSmartArtShapeColorStyle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Traverse through every shape inside first slide
for (int x = 0; x < pres->get_Slides()->idx_get(0)->get_Shapes()->get_Count(); x++)
{
SharedPtr<IShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(x);
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape))
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArt> smart = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArt>(shape);
if (smart->get_ColorStyle() == SmartArtColorType::ColoredFillAccent1)
{
// Changing SmartArt color type
smart->set_ColorStyle(SmartArtColorType::ColorfulAccentColors);
}
}
}
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ChangeSmartArtState_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::BasicProcess);
// Get or Set the state of SmartArt Diagram
smart->set_IsReversed(true);
bool flag = smart->get_IsReversed();
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ChangeTextOnSmartArtNode.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::BasicCycle);
// Accessing SmartArt node at index 0
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArtNode> node = smart->get_AllNodes()->idx_get(0);
// Setting the text of the TextFrame
node->get_TextFrame()->set_Text(u"Second root node");
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ChangingSeriescolor.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Pie, 0, 0, 500, 500);
// Take chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
SharedPtr<IChartDataPoint> point = series->get_DataPoints()->idx_get(1);
point->set_Explosion(30);
point->get_Format()->get_Fill()->set_FillType(FillType::Solid);
point->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Blue());
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/SmartArt.pptx";
const String outPath = u"../out/ChangeSmartArtStyle_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Traverse through every shape inside first slide
for (int x = 0; x < pres->get_Slides()->idx_get(0)->get_Shapes()->get_Count(); x++)
{
SharedPtr<IShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(x);
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape))
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArt> smart = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArt>(shape);
// Checking SmartArt style
if (smart->get_QuickStyle() == SmartArtQuickStyleType::SimpleFill)
{
// Changing SmartArt Style
smart->set_QuickStyle(SmartArtQuickStyleType::Cartoon);
}
}
}
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/FormatChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::LineWithMarkers, 0, 0, 500, 500);
// Setting Chart Titile
chart->set_HasTitle(true);
chart->get_ChartTitle()->AddTextFrameForOverriding(u"");
SharedPtr<IPortion> chartTitle = chart->get_ChartTitle()->get_TextFrameForOverriding()->get_Paragraphs()->idx_get(0)->get_Portions()->idx_get(0);
chartTitle->set_Text(u"Sample Chart");
chartTitle->get_PortionFormat()->get_FillFormat()->set_FillType (FillType::Solid);
chartTitle->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color (System::Drawing::Color::get_Gray());
chartTitle->get_PortionFormat()->set_FontHeight ( 20);
chartTitle->get_PortionFormat()->set_FontBold ( NullableBool::True);
chartTitle->get_PortionFormat()->set_FontItalic ( NullableBool::True);
// Setting Major grid lines format for value axis
chart->get_Axes()->get_VerticalAxis()->get_MajorGridLinesFormat()->get_Line()->get_FillFormat()->set_FillType (FillType::Solid);
chart->get_Axes()->get_VerticalAxis()->get_MajorGridLinesFormat()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Blue());
chart->get_Axes()->get_VerticalAxis()->get_MajorGridLinesFormat()->get_Line()->set_Width ( 5);
chart->get_Axes()->get_VerticalAxis()->get_MajorGridLinesFormat()->get_Line()->set_DashStyle (LineDashStyle::DashDot);
// Setting Minor grid lines format for value axis
chart->get_Axes()->get_VerticalAxis()->get_MinorGridLinesFormat()->get_Line()->get_FillFormat()->set_FillType(Aspose::Slides::FillType::Solid);
chart->get_Axes()->get_VerticalAxis()->get_MinorGridLinesFormat()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
chart->get_Axes()->get_VerticalAxis()->get_MinorGridLinesFormat()->get_Line()->set_Width(3);
// Setting value axis number format
chart->get_Axes()->get_VerticalAxis()->set_IsNumberFormatLinkedToSource ( false);
chart->get_Axes()->get_VerticalAxis()->set_DisplayUnit ( DisplayUnitType::Thousands);
chart->get_Axes()->get_VerticalAxis()->set_NumberFormat(u"0.0%");
// Setting chart maximum, minimum values
chart->get_Axes()->get_VerticalAxis()->set_IsAutomaticMajorUnit(false);
chart->get_Axes()->get_VerticalAxis()->set_IsAutomaticMaxValue(false);
chart->get_Axes()->get_VerticalAxis()->set_IsAutomaticMinorUnit(false);
chart->get_Axes()->get_VerticalAxis()->set_IsAutomaticMinValue(false);
chart->get_Axes()->get_VerticalAxis()->set_MaxValue (15);
chart->get_Axes()->get_VerticalAxis()->set_MinValue ( -2);
chart->get_Axes()->get_VerticalAxis()->set_MinorUnit ( 0.5);
chart->get_Axes()->get_VerticalAxis()->set_MajorUnit ( 2.0);
// Setting Value Axis Text Properties
SharedPtr<IChartPortionFormat> txtVal = chart->get_Axes()->get_VerticalAxis()->get_TextFormat()->get_PortionFormat();
txtVal->set_FontBold ( NullableBool::True);
txtVal->set_FontHeight( 16);
txtVal->set_FontItalic ( NullableBool::True);
txtVal->get_FillFormat()->set_FillType ( FillType::Solid) ;
txtVal->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing:: Color::get_DarkGreen());
SharedPtr<FontData> fontData = MakeObject<FontData>(u"Times New Roman");
//FontDataFactory.CreateFontData //txtVal->set_LatinFont(MakeObject<IFontData>(u"Times New Roman"));
txtVal->set_LatinFont(fontData);
// Setting value axis title
chart->get_Axes()->get_VerticalAxis()->set_HasTitle(true);
chart->get_Axes()->get_VerticalAxis()->get_Title()->AddTextFrameForOverriding(u"");
SharedPtr<IPortion> valtitle = chart->get_Axes()->get_VerticalAxis()->get_Title()->get_TextFrameForOverriding()->get_Paragraphs()->idx_get(0)->get_Portions()->idx_get(0);
valtitle->set_Text(u"Primary Axis");
valtitle->get_PortionFormat()->get_FillFormat()->set_FillType( FillType::Solid);
valtitle->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Gray());
valtitle->get_PortionFormat()->set_FontHeight ( 20);
valtitle->get_PortionFormat()->set_FontBold (NullableBool::True);
valtitle->get_PortionFormat()->set_FontItalic ( NullableBool::True);
// Setting Major grid lines format for Category axis
chart->get_Axes()->get_HorizontalAxis()->get_MajorGridLinesFormat()->get_Line()->get_FillFormat()->set_FillType ( FillType::Solid);
chart->get_Axes()->get_HorizontalAxis()->get_MajorGridLinesFormat()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Green());
chart->get_Axes()->get_HorizontalAxis()->get_MajorGridLinesFormat()->get_Line()->set_Width( 5);
// Setting Minor grid lines format for Category axis
chart->get_Axes()->get_HorizontalAxis()->get_MinorGridLinesFormat()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid);
chart->get_Axes()->get_HorizontalAxis()->get_MinorGridLinesFormat()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Yellow());
chart->get_Axes()->get_HorizontalAxis()->get_MinorGridLinesFormat()->get_Line()->set_Width(3);
// Setting Category Axis Text Properties
SharedPtr<IChartPortionFormat> txtCat = chart->get_Axes()->get_HorizontalAxis()->get_TextFormat()->get_PortionFormat();
txtCat->set_FontBold (NullableBool::True);
txtCat->set_FontHeight ( 16);
txtCat->set_FontItalic ( NullableBool::True);
txtCat->get_FillFormat()->set_FillType( FillType::Solid) ;
txtCat->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Blue());
SharedPtr<FontData> Arial = MakeObject<FontData>(u"Arial");
txtCat->set_LatinFont(Arial);
// Setting Category Titile
chart->get_Axes()->get_HorizontalAxis()->set_HasTitle ( true);
chart->get_Axes()->get_HorizontalAxis()->get_Title()->AddTextFrameForOverriding(u"");
SharedPtr<IPortion> catTitle = chart->get_Axes()->get_HorizontalAxis()->get_Title()->get_TextFrameForOverriding()->get_Paragraphs()->idx_get(0)->get_Portions()->idx_get(0);
catTitle->set_Text(u"Sample Category");
catTitle->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
catTitle->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Gray());
catTitle->get_PortionFormat()->set_FontHeight( 20);
catTitle->get_PortionFormat()->set_FontBold (NullableBool::True);
catTitle->get_PortionFormat()->set_FontItalic ( NullableBool::True);
// Setting category axis lable position
chart->get_Axes()->get_HorizontalAxis()->set_TickLabelPosition( TickLabelPositionType::Low);
// Setting category axis lable rotation angle
chart->get_Axes()->get_HorizontalAxis()->set_TickLabelRotationAngle ( 45);
// Setting Legends Text Properties
SharedPtr<IChartPortionFormat> txtleg = chart->get_Legend()->get_TextFormat()->get_PortionFormat();
txtleg->set_FontBold ( NullableBool::True);
txtleg->set_FontHeight ( 16);
txtleg->set_FontItalic (NullableBool::True);
txtleg->get_FillFormat()->set_FillType (FillType::Solid) ;
txtleg->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_DarkRed());
// Set show chart legends without overlapping chart
chart->get_Legend()->set_Overlay( true);
// Ploting first series on secondary value axis
// Chart.ChartData.Series[0].PlotOnSecondAxis = true;
// Setting chart back wall color
chart->get_BackWall()->set_Thickness( 1);
chart->get_BackWall()->get_Format()->get_Fill()->set_FillType( FillType::Solid);
chart->get_BackWall()->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Orange());
chart->get_Floor()->get_Format()->get_Fill()->set_FillType(FillType::Solid);
chart->get_Floor()->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
// Setting Plot area color
chart->get_PlotArea()->get_Format()->get_Fill()->set_FillType(FillType::Solid);
chart->get_PlotArea()->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_LightCyan());
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ChartTrendLines_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
// Adding ponential trend line for chart series 1
SharedPtr<ITrendline> tredLinep = chart->get_ChartData()->get_Series()->idx_get(0)->get_TrendLines()->Add(Aspose::Slides::Charts::TrendlineType::Exponential);
tredLinep->set_DisplayEquation (false);
tredLinep->set_DisplayRSquaredValue( false);
// Adding Linear trend line for chart series 1
SharedPtr<ITrendline> tredLineLin = chart->get_ChartData()->get_Series()->idx_get(0)->get_TrendLines()->Add(Aspose::Slides::Charts::TrendlineType::Linear);
tredLineLin->set_TrendlineType(TrendlineType::Linear);
tredLineLin->get_Format()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid);
tredLineLin->get_Format()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
// Adding Logarithmic trend line for chart series 2
SharedPtr<ITrendline> tredLineLog = chart->get_ChartData()->get_Series()->idx_get(1)->get_TrendLines()->Add(Aspose::Slides::Charts::TrendlineType::Logarithmic);
tredLineLog->set_TrendlineType(TrendlineType::Logarithmic);
tredLineLog->AddTextFrameForOverriding(u"New log trend line");
// Adding MovingAverage trend line for chart series 2
SharedPtr<ITrendline> tredLineMovAvg = chart->get_ChartData()->get_Series()->idx_get(1)->get_TrendLines()->Add(Aspose::Slides::Charts::TrendlineType::MovingAverage);
tredLineMovAvg->set_TrendlineType(TrendlineType::MovingAverage);
tredLineMovAvg->set_Period(3);
tredLineMovAvg->set_TrendlineName(u"New TrendLine Name");
// Adding Polynomial trend line for chart series 3
SharedPtr<ITrendline> tredLinePol = chart->get_ChartData()->get_Series()->idx_get(2)->get_TrendLines()->Add(Aspose::Slides::Charts::TrendlineType::Polynomial);
tredLinePol->set_TrendlineType(TrendlineType::Polynomial);
tredLinePol->set_Forward (1);
tredLinePol->set_Order (3);
// Adding Power trend line for chart series 3
SharedPtr<ITrendline> tredLinePower = chart->get_ChartData()->get_Series()->idx_get(1)->get_TrendLines()->Add(Aspose::Slides::Charts::TrendlineType::Power);
tredLinePower->set_TrendlineType( TrendlineType::Power);
tredLinePower->set_Backward( 1);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath1 = u"../templates/AccessSlides.pptx";
const String templatePath2 = u"../templates/HelloWorld.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> presentation1 = MakeObject<Presentation>(templatePath1);
SharedPtr<Presentation> presentation2 = MakeObject<Presentation>(templatePath2);
for (int i = 0; i < presentation1->get_Masters()->get_Count(); i++)
{
for (int j = 0; j <presentation2->get_Masters()->get_Count(); j++)
{
if (presentation1->get_Masters()->idx_get(i)->Equals(presentation2->get_Masters()->idx_get(j)))
printf("SomePresentation1 MasterSlide# %d is equal to SomePresentation2 MasterSlide #%d : %d\n",i,j);
}
}
// The path to the documents directory.
const String outPath = u"../out/CheckSmartArtHiddenProperty_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::RadialCycle);
// Adding SmartArt node
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArtNode> NewNode = smart->get_AllNodes()->AddNode();
// Check isHidden property
bool hidden = NewNode->get_IsHidden(); // Returns true
if (hidden)
{
// Do some actions or notifications
}
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templateFile = u"../templates/TestChart.pptx";
const String outPath = u"../out/ClearSpecificChartSeriesDataPointsData.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templateFile);
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
SharedPtr<IChart> chart = System::DynamicCast<IChart>(slide->get_Shapes()->idx_get(0));
// Take chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
for (int i = 0; i < series->get_DataPoints()->get_Count(); i++) {
SharedPtr<IChartDataPoint> dataPoint = series->get_DataPoints()->idx_get(i);
dataPoint->get_XValue()->get_AsCell()->set_Value(nullptr);
dataPoint->get_YValue()->get_AsCell()->set_Value(nullptr);
}
chart->get_ChartData()->get_Series()->idx_get(0)->get_DataPoints()->Clear();
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/CloneAtEndOfAnotherPresentation.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Instantiate target presentation object
SharedPtr<Presentation> destPres = MakeObject<Presentation>();
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slideCollection = destPres->get_Slides();
// Clone the desired slide at end of other presentation
slideCollection->AddClone(pres->get_Slides()->idx_get(0));
// Writing the presentation file
destPres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/CloneAtEndOfAnotherSpecificPosition.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Instantiate target presentation object
SharedPtr<Presentation> destPres = MakeObject<Presentation>();
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slideCollection = destPres->get_Slides();
// Clone the desired slide at end of other presentation
slideCollection->InsertClone(1, pres->get_Slides()->idx_get(0));
// Writing the presentation file
destPres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/CloneAnotherPresentationAtSpecifiedPosition.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Instantiate target presentation object
SharedPtr<Presentation> destPres = MakeObject<Presentation>();
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slideCollection = destPres->get_Slides();
// Clone the desired slide at end of other presentation
slideCollection->InsertClone(1, pres->get_Slides()->idx_get(0));
// Writing the presentation file
destPres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/CloneShapes_out.pptx";
const String templatePath = u"../templates/Source Frame.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> sourceShapes = slide->get_Shapes();
SharedPtr<ILayoutSlide> blankLayout = pres->get_Masters()->idx_get(0)->get_LayoutSlides()->GetByType(SlideLayoutType::Blank);
SharedPtr<ISlide> destSlide = pres->get_Slides()->AddEmptySlide(blankLayout);
SharedPtr<IShapeCollection> destShapes = destSlide->get_Shapes();
destShapes->AddClone(sourceShapes->idx_get(1), 50, 150 + sourceShapes->idx_get(0)->get_Height());
destShapes->AddClone(sourceShapes->idx_get(2));
destShapes->InsertClone(0, sourceShapes->idx_get(0), 50, 150);
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String outPath = u"../out/CloneSlideIntoSpecifiedSection.pptx";
auto presentation = MakeObject<Presentation>();
presentation->get_Slides()->idx_get(0)->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 200.0f, 50.0f, 300.0f, 100.0f);
presentation->get_Sections()->AddSection(u"Section 1", presentation->get_Slides()->idx_get(0));
auto section2 = presentation->get_Sections()->AppendEmptySection(u"Section 2");
presentation->get_Slides()->AddClone(presentation->get_Slides()->idx_get(0), section2);
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/CloneToAnotherPresentationWithMaster.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Instantiate target presentation object
SharedPtr<Presentation> destPres = MakeObject<Presentation>();
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slideCollection = destPres->get_Slides();
// Instantiate ISlide from the collection of slides in source presentation along with
// Master slide
SharedPtr<ISlide> SourceSlide = pres->get_Slides()->idx_get(0);
SharedPtr<IMasterSlide> SourceMaster = SourceSlide->get_LayoutSlide()->get_MasterSlide();
// Clone the desired master slide from the source presentation to the collection of masters in the
// Destination presentation
SharedPtr<IMasterSlideCollection> masters = destPres->get_Masters();
SharedPtr<IMasterSlide> DestMaster = SourceSlide->get_LayoutSlide()->get_MasterSlide();
// Clone the desired master slide from the source presentation to the collection of masters in the
// Destination presentation
SharedPtr<IMasterSlide> iSlide = masters->AddClone(SourceMaster);
// Clone the desired slide from the source presentation with the desired master to the end of the
// Collection of slides in the destination presentation
slideCollection->AddClone(SourceSlide, iSlide, true);
// Clone the desired slide at end of other presentation
slideCollection->InsertClone(1, pres->get_Slides()->idx_get(0));
// Writing the presentation file
destPres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/CloneToAnotherPresentationWithSetSizeAndType.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Instantiate target presentation object
SharedPtr<Presentation> destPres = MakeObject<Presentation>();
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slideCollection = destPres->get_Slides();
// Set the slide size of generated presentations to that of source
destPres->get_SlideSize()->SetSize(pres->get_SlideSize()->get_Type(), Aspose::Slides::SlideSizeScaleType::DoNotScale);
// destPres->get_SlideSize()->set_Size(Size(pres->get_SlideSize()->get_Type(),);
// Clone the desired slide at desired position of other presentation
slideCollection->InsertClone(1, pres->get_Slides()->idx_get(0));
// Writing the presentation file
destPres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/CloneWithInSamePresentation.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slides = pres->get_Slides();
// Clone the desired slide to the specified index in the same presentation
slides->InsertClone(2, pres->get_Slides()->idx_get(0));
// Writing the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/CloneWithinSamePresentationToEnd.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slides = pres->get_Slides();
// Clone the desired slide at end of same presentation
slides->AddClone(pres->get_Slides()->idx_get(0));
// Writing the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/CloningInTable_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> islide = pres->get_Slides()->idx_get(0);
// Define columns with widths and rows with heights
System::ArrayPtr<double> dblCols = System::MakeObject<System::Array<double>>(4, 70);
System::ArrayPtr<double> dblRows = System::MakeObject<System::Array<double>>(4, 70);
// Add table shape to slide
SharedPtr<ITable> table = islide->get_Shapes()->AddTable(100, 50, dblCols, dblRows);
// Set border format for each cell
for (int x = 0; x < table->get_Rows()->get_Count(); x++)
{
SharedPtr<IRow> row = table->get_Rows()->idx_get(x);
for (int y = 0; y < row->get_Count(); y++)
{
SharedPtr<ICell> cell = row->idx_get(y);
cell->get_BorderTop()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderTop()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderTop()->set_Width(5);
cell->get_BorderBottom()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderBottom()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderBottom()->set_Width(5);
cell->get_BorderLeft()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderLeft()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderLeft()->set_Width(5);
cell->get_BorderRight()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderRight()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderRight()->set_Width(5);
}
}
table->idx_get(0, 0)->get_TextFrame()->set_Text(u"00");
table->idx_get(0, 1)->get_TextFrame()->set_Text(u"01");
table->idx_get(0, 2)->get_TextFrame()->set_Text(u"02");
table->idx_get(0, 3)->get_TextFrame()->set_Text(u"03");
table->idx_get(1, 0)->get_TextFrame()->set_Text(u"10");
table->idx_get(2, 0)->get_TextFrame()->set_Text(u"20");
table->idx_get(1, 1)->get_TextFrame()->set_Text(u"11");
table->idx_get(2, 1)->get_TextFrame()->set_Text(u"21");
//AddClone adds a row in the end of the table
table->get_Rows()->AddClone(table->get_Rows()->idx_get(0), false);
//InsertClone adds a row at specific position in a table
table->get_Rows()->InsertClone(2, table->get_Rows()->idx_get(0), false);
//AddClone adds a column in the end of the table
table->get_Columns()->AddClone(table->get_Columns()->idx_get(0), false);
//InsertClone adds a column at specific position in a table
table->get_Columns()->InsertClone(2, table->get_Columns()->idx_get(0), false);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
double getDirection(float w, float h, Aspose::Slides::NullableBool flipH, Aspose::Slides::NullableBool flipV)
{
float endLineX = w;
if (flipH == NullableBool::True)
endLineX = endLineX * -1;
else
endLineX = endLineX * 1;
//float endLineX = w * (flipH ? -1 : 1);
float endLineY = h;
if (flipV == NullableBool::True)
endLineY = endLineY * -1;
else
endLineY = endLineY * 1;
// float endLineY = h * (flipV ? -1 : 1);
float endYAxisX = 0;
float endYAxisY = h;
double angle = (Math::Atan2(endYAxisY, endYAxisX) - Math::Atan2(endLineY, endLineX));
if (angle < 0) angle += 2 * Math::PI;
return angle * 180.0 / Math::PI;
}
void ConnectorLineAngle()
{
// The path to the documents directory.
const String outPath = u"../out/ConnectorLineAngle_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
for (int i = 0; i < slide->get_Shapes()->get_Count(); i++)
{
double dir = 0.0;
// Accessing the shape collection of slides
System::SharedPtr<IShape> shape = slide->get_Shapes()->idx_get(i);
if (System::ObjectExt::Is<AutoShape>(shape))
{
SharedPtr<AutoShape> aShape = DynamicCast<Aspose::Slides::AutoShape>(shape);
if (aShape->get_ShapeType() == ShapeType::Line)
{
// dir = getDirection(aShape->get_Width(), aShape->get_Height(), Convert::ToBoolean(aShape->get_Frame()->get_FlipH()), Convert::ToBoolean(aShape->get_Frame()->get_FlipV()));
dir = getDirection(aShape->get_Width(), aShape->get_Height(), aShape->get_Frame()->get_FlipH(), aShape->get_Frame()->get_FlipV());
}
}
else if (System::ObjectExt::Is<Connector>(shape))
{
SharedPtr<Connector> aShape = DynamicCast<Aspose::Slides::Connector>(shape);
// dir = getDirection(aShape->get_Width(), aShape->get_Height(), Convert::ToBoolean(aShape->get_Frame()->get_FlipH()), Convert::ToBoolean(aShape->get_Frame()->get_FlipV()));
dir = getDirection(aShape->get_Width(), aShape->get_Height(), aShape->get_Frame()->get_FlipH(),aShape->get_Frame()->get_FlipV());
}
Console::WriteLine(dir);
}
}
//double ConnectorLineAngle::getDirection(float w, float h, NullableBool flipH, NullableBool flipV)
// The path to the documents directory.
const String outPath = u"../out/ConnectShapesUsingConnectors_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Add an autoshape of type Ellipse
SharedPtr<IAutoShape> ellipse = slide->get_Shapes()->AddAutoShape(ShapeType::Ellipse, 0, 100, 100, 100);
// Add an autoshape of type rectangle
SharedPtr<IAutoShape> rect = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 100, 300, 100, 100);
// Adding connector shape to slide shape collection
SharedPtr<IConnector> connector = shapes->AddConnector(ShapeType::BentConnector2, 0, 0, 10, 10);
// Joining Shapes to connectors
connector->set_StartShapeConnectedTo ( ellipse);
connector->set_EndShapeConnectedTo (rect);
// Call reroute to set the automatic shortest path between shapes
connector->Reroute();
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ConnectShapeUsingConnectionSite_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Add an autoshape of type Ellipse
SharedPtr<IAutoShape> ellipse = slide->get_Shapes()->AddAutoShape(ShapeType::Ellipse, 0, 100, 100, 100);
// Add an autoshape of type rectangle
SharedPtr<IAutoShape> rect = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 100, 200, 100, 100);
// Adding connector shape to slide shape collection
SharedPtr<IConnector> connector = shapes->AddConnector(ShapeType::BentConnector3, 0, 0, 10, 10);
// Joining Shapes to connectors
connector->set_StartShapeConnectedTo(ellipse);
connector->set_EndShapeConnectedTo(rect);
// Setting the desired connection site index of Ellipse shape for connector to get connected
int wantedIndex = 6;
// Checking if desired index is less than maximum site index count
if (ellipse->get_ConnectionSiteCount() > wantedIndex)
{
// Setting the desired connection site for connector on Ellipse
connector->set_StartShapeConnectionSiteIndex ( wantedIndex);
}
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ConversionToTIFFNotes_out.tiff";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
System::SharedPtr<TiffOptions> opts = System::MakeObject<TiffOptions>();
System::SharedPtr<INotesCommentsLayoutingOptions> options = opts->get_NotesCommentsLayouting();
options->set_NotesPosition(NotesPositions::BottomFull);
//Saving to TiffNotes
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Tiff, opts);
// The path to the documents directory.
// const String outPath = u"../out/ConvertWholePresentationToHTML_out.html";
const String outPath = u"../out/";
const String templatePath = u"../templates/AccessSlides.pptx";
// ConvertIndividualSlide::Run();
//Instantiate Presentation class that represents PPTX file
//SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// ResponsiveHtmlController controller = new ResponsiveHtmlController();
//SharedPtr<Aspose::Slides::Export::ResponsiveHtmlController> controller = MakeObject <Aspose::Slides::Export::ResponsiveHtmlController>();
// SharedPtr<Aspose::Slides::Export::HtmlOptions> htmlOptions = MakeObject <Aspose::Slides::Export::HtmlOptions>();
//htmlOptions->set_HtmlFormatter((HtmlFormatter::CreateSlideShowFormatter(u"", false)));
// htmlOptions->set_HtmlFormatter(HtmlFormatter::CreateCustomFormatter(System::MakeObject<ConvertIndividualSlide::CustomFormattingController>()));
// htmlOptions->set_IncludeComments( true);
// Saving File
/*for (int i = 0; i < pres->get_Slides()->get_Count(); i++)
{
pres->Save(outPath + u"Individual Slide" + (i + 1) + u"_out.html", System::MakeArray<int32_t>({ i + 1 }), SaveFormat::Html, htmlOptions);
}*/
const String outPath = u"../out/PresentationToHtmlWithEmbedAllFontsHtmlController_out.hmtl";
const String templatePath = u"../templates/AccessSlides.pptx";
{
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
// Clearing resources under 'using' statement
//System::Details::DisposeGuard __dispose_guard_0{ pres, ASPOSE_CURRENT_FUNCTION };
// ------------------------------------------
// exclude default presentation fonts
System::ArrayPtr<System::String> fontNameExcludeList = System::MakeArray<System::String>({u"Calibri", u"Arial"});
System::SharedPtr<Paragraph> para = System::MakeObject<Paragraph>();
System::SharedPtr<ITextFrame> txt;
System::SharedPtr<EmbedAllFontsHtmlController> embedFontsController = System::MakeObject<EmbedAllFontsHtmlController>(fontNameExcludeList);
System::SharedPtr<LinkAllFontsHtmlController> linkcont = System::MakeObject<LinkAllFontsHtmlController>(fontNameExcludeList, u"C:\\Windows\\Fonts\\");
System::SharedPtr<HtmlOptions> htmlOptionsEmbed = [&]{ auto tmp_0 = System::MakeObject<HtmlOptions>(); tmp_0->set_HtmlFormatter(HtmlFormatter::CreateCustomFormatter(linkcont)); return tmp_0; }();
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Html, htmlOptionsEmbed);
const String outPath = u"../out/oHTMLWithPreservingOriginalFonts_out.hmtl";
const String templatePath = u"../templates/AccessSlides.pptx";
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// exclude default presentation fonts
ArrayPtr<String> fontNameExcludeList =MakeArray<String>( { u"Calibri", u"Arial" });
SharedPtr<EmbedAllFontsHtmlController> embedFontsController = MakeObject< EmbedAllFontsHtmlController>(fontNameExcludeList);
SharedPtr<HtmlOptions> htmlOptionsEmbed = MakeObject< HtmlOptions>();
htmlOptionsEmbed->set_HtmlFormatter(HtmlFormatter::CreateCustomFormatter(embedFontsController));
System::SharedPtr<INotesCommentsLayoutingOptions> options = htmlOptionsEmbed->get_NotesCommentsLayouting();
options->set_NotesPosition(NotesPositions::BottomFull);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Html, htmlOptionsEmbed);
// The path to the documents directory.
const String outPath = u"../out/ConvertNotesSlideViewToPDF_out.pdf";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
System::SharedPtr<PdfOptions> opts = System::MakeObject<PdfOptions>();
System::SharedPtr<INotesCommentsLayoutingOptions> options = opts->get_NotesCommentsLayouting();
options->set_NotesPosition(NotesPositions::BottomFull);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pdf, opts);
// The path to the documents directory.
// The path to the documents directory.
const String outPath = u"../out/ConvertPresentationToPasswordProtectedPDF_out.pdf";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
SharedPtr<Aspose::Slides::Export::PdfOptions> pdfoptions = MakeObject <Aspose::Slides::Export::PdfOptions>();
pdfoptions->set_Password(u"password");
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pdf, pdfoptions);
// The path to the documents directory.
const String outPath = u"../out/ConvertPresentationToResponsiveHTML_out.html";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// ResponsiveHtmlController controller = new ResponsiveHtmlController();
SharedPtr<Aspose::Slides::Export::ResponsiveHtmlController> controller = MakeObject <Aspose::Slides::Export::ResponsiveHtmlController>();
System::SharedPtr<HtmlOptions> htmlOptions = System::MakeObject<HtmlOptions>();
htmlOptions->set_HtmlFormatter(HtmlFormatter::CreateCustomFormatter(controller));
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Html, htmlOptions);
System::String pptxFileName = u"../templates/image.pptx";
System::String outPptxPath = u"../out/image_group.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(pptxFileName);
System::SharedPtr<PictureFrame> pFrame = System::DynamicCast_noexcept<Aspose::Slides::PictureFrame>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));
System::SharedPtr<ISvgImage> svgImage = pFrame->get_PictureFormat()->get_Picture()->get_Image()->get_SvgImage();
if (svgImage != nullptr)
{
// Convert svg image into group of shapes
System::SharedPtr<IShapeFrame> shapeFrame = pFrame->get_Frame();
System::SharedPtr<IGroupShape> groupShape = pres->get_Slides()->idx_get(0)->get_Shapes()->AddGroupShape(svgImage, shapeFrame->get_X(), shapeFrame->get_Y(), shapeFrame->get_Width(), shapeFrame->get_Height());
// remove source svg image from presentation
pres->get_Slides()->idx_get(0)->get_Shapes()->Remove(pFrame);
pres->Save(outPptxPath, Aspose::Slides::Export::SaveFormat::Pptx);
}
// The path to the documents directory.
const String outPath = u"../out/ConvertToPDF_out.pdf";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pdf);
// The path to the documents directory.
const String outPath = u"../out/ConvertToPDFWithHiddenSlides_out.pdf";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
SharedPtr<Aspose::Slides::Export::PdfOptions> pdfOptions = MakeObject <Aspose::Slides::Export::PdfOptions>();
pdfOptions->set_ShowHiddenSlides(true);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pdf, pdfOptions);
// The path to the documents directory.
const String outPath = u"../out/ConvertToSWF_out.swf";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
SharedPtr<Aspose::Slides::Export::SwfOptions> swfOptions = MakeObject <Aspose::Slides::Export::SwfOptions>();
swfOptions->set_ViewerIncluded ( true);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Swf, swfOptions);
// The path to the documents directory.
const String outPath = u"../out/ConvertWholePresentationToHTML_out.html";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// ResponsiveHtmlController controller = new ResponsiveHtmlController();
SharedPtr<Aspose::Slides::Export::ResponsiveHtmlController> controller = MakeObject <Aspose::Slides::Export::ResponsiveHtmlController>();
SharedPtr<Aspose::Slides::Export::HtmlOptions> htmlOptions = MakeObject <Aspose::Slides::Export::HtmlOptions>();
htmlOptions->set_HtmlFormatter((HtmlFormatter::CreateSlideShowFormatter(u"", false)));
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Html, htmlOptions);
// The path to the documents directory.
const String outPath = u"../out/ConvertWithoutXpsOptions_out.xps";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Xps);
// The path to the documents directory.
const String outPath = u"../out/ConvertWithXpsOptions_out.xps";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
SharedPtr<Aspose::Slides::Export::XpsOptions> xpsOptions = MakeObject <Aspose::Slides::Export::XpsOptions>();
xpsOptions->set_SaveMetafilesAsPng(true);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Xps, xpsOptions);
Paragraph CopyParagraph(SharedPtr<IParagraph> par)
{
SharedPtr<Paragraph> para = MakeObject<Paragraph>();
// use CreateParagraphFormatData !!!
SharedPtr<IParagraphFormatEffectiveData> paraData = par->CreateParagraphFormatEffective();
// use ParagraphFormat to set values
para->get_ParagraphFormat()->set_Alignment(paraData->get_Alignment());
para->get_ParagraphFormat()->set_DefaultTabSize(paraData->get_DefaultTabSize());
para->get_ParagraphFormat()->set_MarginLeft(paraData->get_MarginLeft());
para->get_ParagraphFormat()->set_MarginRight(paraData->get_MarginRight());
para->get_ParagraphFormat()->set_FontAlignment(paraData->get_FontAlignment());
para->get_ParagraphFormat()->set_Indent(paraData->get_Indent());
para->get_ParagraphFormat()->set_Depth(paraData->get_Depth());
para->get_ParagraphFormat()->set_SpaceAfter(paraData->get_SpaceAfter());
para->get_ParagraphFormat()->set_SpaceBefore(paraData->get_SpaceBefore());
para->get_ParagraphFormat()->set_SpaceWithin(paraData->get_SpaceWithin());
para->get_ParagraphFormat()->get_Bullet()->set_Type(paraData->get_Bullet()->get_Type());
para->get_ParagraphFormat()->get_Bullet()->set_Char(paraData->get_Bullet()->get_Char());
para->get_ParagraphFormat()->get_Bullet()->get_Color()->set_Color(paraData->get_Bullet()->get_Color()) ;
para->get_ParagraphFormat()->get_Bullet()->set_Height(paraData->get_Bullet()->get_Height()) ;
para->get_ParagraphFormat()->get_Bullet()->set_Font(paraData->get_Bullet()->get_Font());
para->get_ParagraphFormat()->get_Bullet()->set_NumberedBulletStyle(paraData->get_Bullet()->get_NumberedBulletStyle());
para->get_ParagraphFormat()->set_FontAlignment(paraData->get_FontAlignment()) ;
para->get_ParagraphFormat()->set_RightToLeft(paraData->get_RightToLeft() ? NullableBool::True : NullableBool::False);
para->get_ParagraphFormat()->set_EastAsianLineBreak(paraData->get_EastAsianLineBreak() ? NullableBool::True : NullableBool::False);
para->get_ParagraphFormat()->set_HangingPunctuation(paraData->get_HangingPunctuation() ? NullableBool::True : NullableBool::False);
return para;
}
Portion CopyPortion(SharedPtr<IPortion> por)
{
SharedPtr<Portion> temp = MakeObject<Portion>();
//use CreatePortionFormatData!!!
SharedPtr<IPortionFormatEffectiveData> portData = por->CreatePortionFormatEffective();
// use PortionFormat to set values
temp->get_PortionFormat()->set_AlternativeLanguageId(portData->get_AlternativeLanguageId());
temp->get_PortionFormat()->set_BookmarkId(portData->get_BookmarkId()) ;
temp->get_PortionFormat()->set_Escapement(portData->get_Escapement()) ;
temp->get_PortionFormat()->get_FillFormat()->set_FillType(por->get_PortionFormat()->get_FillFormat()->get_FillType());
temp->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(portData->get_FillFormat()->get_SolidFillColor()) ;
temp->get_PortionFormat()->set_FontBold(portData->get_FontBold() ? NullableBool::True : NullableBool::False);
temp->get_PortionFormat()->set_FontHeight(portData->get_FontHeight());
temp->get_PortionFormat()->set_FontItalic(portData->get_FontItalic() ? NullableBool::True : NullableBool::False);
temp->get_PortionFormat()->set_FontUnderline(portData->get_FontUnderline());
temp->get_PortionFormat()->get_UnderlineFillFormat()->set_FillType(portData->get_UnderlineFillFormat()->get_FillType());
temp->get_PortionFormat()->get_UnderlineFillFormat()->get_SolidFillColor()->set_Color(portData->get_UnderlineFillFormat()->get_SolidFillColor());
temp->get_PortionFormat()->set_IsHardUnderlineFill(portData->get_IsHardUnderlineFill() ? NullableBool::True : NullableBool::False);
temp->get_PortionFormat()->set_IsHardUnderlineLine(portData->get_IsHardUnderlineLine() ? NullableBool::True : NullableBool::False);
temp->get_PortionFormat()->set_KerningMinimalSize(portData->get_KerningMinimalSize()) ;
temp->get_PortionFormat()->set_Kumimoji(portData->get_Kumimoji() ? NullableBool::True : NullableBool::False);
temp->get_PortionFormat()->set_LanguageId(portData->get_LanguageId());
temp->get_PortionFormat()->set_LatinFont(portData->get_LatinFont()) ;
temp->get_PortionFormat()->set_EastAsianFont(portData->get_EastAsianFont());
temp->get_PortionFormat()->set_ComplexScriptFont(portData->get_ComplexScriptFont());
temp->get_PortionFormat()->set_SymbolFont(portData->get_SymbolFont());
temp->get_PortionFormat()->set_TextCapType(portData->get_TextCapType());
temp->get_PortionFormat()->set_Spacing(portData->get_Spacing());
temp->get_PortionFormat()->set_StrikethroughType(portData->get_StrikethroughType());
temp->get_PortionFormat()->set_ProofDisabled(portData->get_ProofDisabled() ? NullableBool::True : NullableBool::False);
temp->get_PortionFormat()->set_NormaliseHeight(portData->get_NormaliseHeight() ? NullableBool::True : NullableBool::False);
temp->get_PortionFormat()->set_HyperlinkMouseOver(portData->get_HyperlinkMouseOver());
temp->get_PortionFormat()->set_HyperlinkClick(por->get_PortionFormat()->get_HyperlinkClick());
temp->get_PortionFormat()->get_HighlightColor()->set_Color(portData->get_HighlightColor());
return temp;
}
const String templatePath = u"../templates/SamplePresentation.pptx";
const String outPath = u"../out/SamplePresentation_out.pptx";
auto presentation = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<ISaveOptions> saveOptions = System::MakeObject<PdfOptions>();
System::SharedPtr<IProgressCallback> callBack = System::MakeObject<ExportProgressHandler>();
saveOptions->set_ProgressCallback(callBack);
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pdf, saveOptions);
class ExportProgressHandler : public IProgressCallback
{
public:
void Reporting(double progressValue)
{
System::Console::WriteLine(u"% completed", progressValue);
}
};
// The path to the documents directory.
const String outPath = u"../out/Shape_thumbnail_Bound_Shape_out.png";
const String templatePath = u"../templates/HelloWorld.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
auto bitmap = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)->GetThumbnail(ShapeThumbnailBounds::Appearance, 1, 1);
// Save the image to disk in PNG format
bitmap->Save(outPath, System::Drawing::Imaging::ImageFormat::get_Png());
const String templatePath = u"../templates/presentaion.pptx";
const String externalWbPath = u"../externalWorkbook1.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<Aspose::Slides::Charts::IChart> chart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Pie, 50.0f, 50.0f, 400.0f, 600.0f);
if (System::IO::File::Exists(externalWbPath))
System::IO::File::Delete(externalWbPath);
System::SharedPtr<System::IO::FileStream> fileStream = System::MakeObject<System::IO::FileStream>(externalWbPath, System::IO::FileMode::CreateNew);
System::ArrayPtr<uint8_t> worbookData = chart->get_ChartData()->ReadWorkbookStream()->ToArray();
fileStream->Write(worbookData, 0, worbookData->get_Length());
fileStream->Close();
chart->get_ChartData()->SetExternalWorkbook(externalWbPath);
// The path to the documents directory.
const String outPath = u"../out/CreateGroupShape_out.pptx";
const String templatePath = u"../templates/Source Frame.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> slideShapes = slide->get_Shapes();
// Adding a group shape to the slide
SharedPtr<IGroupShape> groupShape = slideShapes->AddGroupShape();
// Adding shapes inside added group shape
groupShape->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 300, 100, 100, 100);
groupShape->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 500, 100, 100, 100);
groupShape->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 300, 300, 100, 100);
groupShape->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 500, 300, 100, 100);
// Adding group shape frame
groupShape->set_Frame( MakeObject<ShapeFrame>(100, 300, 500, 40, NullableBool::False, NullableBool::False, 0));
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/SampleChartresult.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add an autoshape of type line
slide->get_Shapes()->AddAutoShape(Aspose::Slides::ShapeType::Line, 50.0, 150.0, 300.0, 0.0);
//Saving presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/CreateScalingFactorThumbnail_out.png";
const String templatePath = u"../templates/HelloWorld.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
auto bitmap = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)->GetThumbnail(ShapeThumbnailBounds::Shape, 2, 2);
// Save the image to disk in PNG format
bitmap->Save(outPath, System::Drawing::Imaging::ImageFormat::get_Png());
// The path to the documents directory.
const String outPath = u"../out/CreateShapeSVGImage_out.svg";
const String templatePath = u"../templates/HelloWorld.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access the first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Create a memory stream object
SharedPtr<System::IO::MemoryStream> SvgStream = MakeObject<System::IO::MemoryStream>();
// Generate SVG image of slide shape at index 0 and save in memory stream
slide->get_Shapes()->idx_get(0)->WriteAsSvg(SvgStream);
SvgStream->set_Position(0);
// Save memory stream to file
try
{
System::SharedPtr<System::IO::Stream> fileStream = System::IO::File::OpenWrite(outPath);
System::ArrayPtr<uint8_t> buffer = System::MakeObject<System::Array<uint8_t>>(8 * 1024, 0);
int32_t len;
while ((len = SvgStream->Read(buffer, 0, buffer->get_Length())) > 0)
{
fileStream->Write(buffer, 0, len);
}
}
catch (Exception e)
{
}
SvgStream->Close();
// The path to the documents directory.
const String outPath = u"../out/CreateShapeThumbnail_out.png";
const String templatePath = u"../templates/HelloWorld.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
auto bitmap = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)->GetThumbnail();
// Save the image to disk in PNG format
bitmap->Save(outPath, System::Drawing::Imaging::ImageFormat::get_Png());
// The path to the documents directory.
const String templatePath = u"../templates/TestDeck_050.pptx";
const String outPath = u"../out/Aspose_out.svg";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access the first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Create a memory stream object
SharedPtr<System::IO::MemoryStream> SvgStream = MakeObject<System::IO::MemoryStream>();
// Generate SVG image of slide and save in memory stream
slide->WriteAsSvg(SvgStream);
SvgStream->set_Position(0);
// Save memory stream to file
try
{
System::SharedPtr<System::IO::Stream> fileStream = System::IO::File::OpenWrite(outPath);
System::ArrayPtr<uint8_t> buffer = System::MakeObject<System::Array<uint8_t>>(8 * 1024, 0);
int32_t len;
while ((len = SvgStream->Read(buffer, 0, buffer->get_Length())) > 0)
{
fileStream->Write(buffer, 0, len);
}
}
catch (Exception e)
{
}
SvgStream->Close();
// The path to the documents directory.
const String outPath = u"../out/CreateSmartArtChildNoteThumbnail_out.png";
const String templatePath = u"../templates/HelloWorld.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt
SharedPtr<ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::BasicCycle);
// Obtain the reference of a node by using its Index
SharedPtr<ISmartArtNode> node = smart->get_Nodes()->idx_get(1);
// Get thumbnail
auto bitmap = node->get_Shapes()->idx_get(0)->GetThumbnail();
// Save the image to disk in PNG format
bitmap->Save(outPath, System::Drawing::Imaging::ImageFormat::get_Png());
// The path to the documents directory.
const String outPath = u"../out/SimpleSmartArt_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::BasicBlockList);
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
System::SharedPtr<ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(20, 20, 600, 500, Aspose::Slides::SmartArt::SmartArtLayoutType::OrganizationChart);
// Move SmartArt shape to new position
System::SharedPtr<ISmartArtNode> node = smart->get_AllNodes()->idx_get(1);
System::SharedPtr<ISmartArtShape> shape = node->get_Shapes()->idx_get(1);
shape->set_X((float)(shape->get_X() + (shape->get_Width() * 2)));
shape->set_Y((float)(shape->get_Y() - (shape->get_Height() / 2)));
// Change SmartArt shape's widths
node = smart->get_AllNodes()->idx_get(2);
shape = node->get_Shapes()->idx_get(1);
shape->set_Width(shape->get_Width() + (shape->get_Width() / 2));
// Change SmartArt shape's height
node = smart->get_AllNodes()->idx_get(3);
shape = node->get_Shapes()->idx_get(1);
shape->set_Height(shape->get_Height() + (shape->get_Height() / 2));
// Change SmartArt shape's rotation
node = smart->get_AllNodes()->idx_get(4);
shape = node->get_Shapes()->idx_get(1);
shape->set_Rotation(90);
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
class CustomHeaderAndFontsController : public Aspose::Slides::Export::EmbedAllFontsHtmlController
{
typedef CustomHeaderAndFontsController ThisType;
typedef Aspose::Slides::Export::EmbedAllFontsHtmlController BaseType;
typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
RTTI_INFO_DECL();
public:
CustomHeaderAndFontsController(System::String cssFileName);
virtual void WriteDocumentStart(System::SharedPtr<Aspose::Slides::Export::IHtmlGenerator> generator, System::SharedPtr<IPresentation> presentation);
virtual void WriteAllFonts(System::SharedPtr<Aspose::Slides::Export::IHtmlGenerator> generator, System::SharedPtr<IPresentation> presentation);
private:
static const System::String Header;
System::String m_cssFileName;
};
// The path to the documents directory.
const String outPath = u"../out/CustomOptionsPDFConversion_out.pdf";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
SharedPtr<Aspose::Slides::Export::PdfOptions> pdfOptions = MakeObject <Aspose::Slides::Export::PdfOptions>();
pdfOptions->set_ShowHiddenSlides(true);
pdfOptions->set_JpegQuality(90);
pdfOptions->set_SaveMetafilesAsPng(true);
pdfOptions->set_TextCompression(PdfTextCompression::Flate);
pdfOptions->set_Compliance(PdfCompliance::Pdf15);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pdf, pdfOptions);
// The path to the documents directory.
const String outPath = u"../out/CustomRotationAngleTextframe_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IChart> chart = sld->get_Shapes()->AddChart(ChartType::ClusteredColumn, 50, 50, 500, 300);
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true);
series->get_Labels()->get_DefaultDataLabelFormat()->get_TextFormat()->get_TextBlockFormat()->set_RotationAngle(65);
chart->set_HasTitle (true);
chart->get_ChartTitle()->AddTextFrameForOverriding(u"Custom title")->get_TextFrameFormat()->set_RotationAngle ( -30);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
/*class CustomSvgShapeFormattingController: public ISvgShapeFormattingController
{
int m_shapeIndex;
CustomSvgShapeFormattingController(int shapeStartIndex = 0)
{
m_shapeIndex = shapeStartIndex;
}
public:
void FormatShape(SvgShape svgShape, Shape shape)
{
svgShape.set_Id(String::Format(L"Shape-{0}", m_shapeIndex++));
}
};*/
/*void CustomSvgShapeFormattingController::FormatShape(SvgShape svgShape, Shape shape)
{
svgShape.set_Id(String::Format(L"Shape-{0}", m_shapeIndex++));
}*/
// The path to the documents directory.
const String outPath = u"../out/DateFormatForCategoryAxis_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Area, 0, 0, 500, 500);
//Accessing chart workbook
SharedPtr<IChartDataWorkbook> wb = chart->get_ChartData()->get_ChartDataWorkbook();
wb->Clear(0);
//System::DateTime::get_Now()
chart->get_ChartData()->get_Categories()->Clear();
chart->get_ChartData()->get_Series()->Clear();
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A2", System::ObjectExt::Box<double>(System::DateTime(2015, 1, 1).ToOADate())));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A3", System::ObjectExt::Box<double>(System::DateTime(2016, 1, 1).ToOADate())));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A4", System::ObjectExt::Box<double>(System::DateTime(2017, 1, 1).ToOADate())));
chart->get_ChartData()->get_Categories()->Add(wb->GetCell(0, u"A5", System::ObjectExt::Box<double>(System::DateTime(2018, 1, 1).ToOADate())));
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->Add(ChartType::Line);
series->get_DataPoints()->AddDataPointForLineSeries(wb->GetCell(0, u"B2", ObjectExt::Box<double>(1)));
series->get_DataPoints()->AddDataPointForLineSeries(wb->GetCell(0, u"B3", ObjectExt::Box<double>(2)));
series->get_DataPoints()->AddDataPointForLineSeries(wb->GetCell(0, u"B4", ObjectExt::Box<double>(3)));
series->get_DataPoints()->AddDataPointForLineSeries(wb->GetCell(0, u"B5", ObjectExt::Box<double>(4)));
chart->get_Axes()->get_HorizontalAxis()->set_CategoryAxisType ( CategoryAxisType::Date);
chart->get_Axes()->get_HorizontalAxis()->set_IsNumberFormatLinkedToSource ( false);
chart->get_Axes()->get_HorizontalAxis()->set_NumberFormat (u"yyyy");
// Accessing the chart series collection
SharedPtr<IChartSeriesCollection> seriesCollection = chart->get_ChartData()->get_Series();
// Setting the position of label from axis
chart->get_Axes()->get_HorizontalAxis()->set_LabelOffset(500);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/DefaultFonts_out.pptx";
const String tempplatePath = u"../templates/DefaultFonts.pptx";
// Use load options to define the default regualr and asian fonts// Use load options to define the default regualr and asian fonts
SharedPtr<LoadOptions> loadOptions = MakeObject< LoadOptions>(LoadFormat::Auto);
loadOptions->set_DefaultRegularFont(u"Wingdings");
loadOptions->set_DefaultAsianFont(u"Wingdings");
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(tempplatePath,loadOptions);
// Generate slide thumbnail
pres->get_Slides()->idx_get(0)->GetThumbnail(1, 1)->Save(u"../out/DefaultFonts_out.png", System::Drawing::Imaging::ImageFormat::get_Png());
// Generate PDF
pres->Save(u"../out/DefaultFonts_out.pdf", Aspose::Slides::Export::SaveFormat::Pdf);
// Generate XPS
pres->Save(u"../out/DefaultFonts_out.xps", Aspose::Slides::Export::SaveFormat::Xps);
// The path to the documents directory.
const String outPath = u"../out/DefaultMarkersInChart.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Accessing the first slide in presentation
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::LineWithMarkers, 10, 10, 400, 400);
chart->get_ChartData()->get_Series()->Clear();
chart->get_ChartData()->get_Categories()->Clear();
System::SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();
chart->get_ChartData()->get_Series()->Add(fact->GetCell(0,0,1, System::ObjectExt::Box<System::String>(u"Category 1")),chart->get_Type());
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(0, 1, 0, ObjectExt::Box<System::String>(u"C1")));
series->get_DataPoints()->AddDataPointForLineSeries(fact->GetCell(0, 1, 1, System::ObjectExt::Box<int32_t>(24)));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(0, 2, 0, ObjectExt::Box<System::String>(u"C2")));
series->get_DataPoints()->AddDataPointForLineSeries(fact->GetCell(0, 2, 1, System::ObjectExt::Box<int32_t>(23)));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(0, 3, 0, ObjectExt::Box<System::String>(u"C3")));
series->get_DataPoints()->AddDataPointForLineSeries(fact->GetCell(0, 3, 1, System::ObjectExt::Box<int32_t>(-10)));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(0, 4, 0, ObjectExt::Box<System::String>(u"C4")));
series->get_DataPoints()->AddDataPointForLineSeries(fact->GetCell(0, 4, 1, nullptr));
chart->get_ChartData()->get_Series()->Add(fact->GetCell(0, 0, 2, ObjectExt::Box<System::String>(u"Series 2")), chart->get_Type());
//Take second chart series
SharedPtr<IChartSeries> series2 = chart->get_ChartData()->get_Series()->idx_get(1);
//Now populating series data
series2->get_DataPoints()->AddDataPointForLineSeries(fact->GetCell(0, 1, 2, System::ObjectExt::Box<int32_t>(30)));
series2->get_DataPoints()->AddDataPointForLineSeries(fact->GetCell(0, 2, 2, System::ObjectExt::Box<int32_t>(10)));
series2->get_DataPoints()->AddDataPointForLineSeries(fact->GetCell(0, 3, 2, System::ObjectExt::Box<int32_t>(60)));
series2->get_DataPoints()->AddDataPointForLineSeries(fact->GetCell(0, 4, 2, System::ObjectExt::Box<int32_t>(40)));
chart->set_HasLegend(true);
chart->get_Legend()->set_Overlay(false);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// pres->Print();
// The path to the documents directory.
const String outPath = u"../out/DisplayChartLabels_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Pie, 0, 0, 500, 500);
chart->get_ChartData()->get_Series()->idx_get(0)->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue ( true);
chart->get_ChartData()->get_Series()->idx_get(0)->get_Labels()->get_DefaultDataLabelFormat()->set_ShowLabelAsDataCallout( true);
chart->get_ChartData()->get_Series()->idx_get(0)->get_Labels()->idx_get(2)->get_DataLabelFormat()->set_ShowLabelAsDataCallout ( false);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/DisplayPercentageAsLabels_out.pptx";
// Create an instance of Presentation class
System::SharedPtr<Presentation> presentation = System::MakeObject<Presentation>();
System::SharedPtr<ISlide> slide = presentation->get_Slides()->idx_get(0);
System::SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::StackedColumn, 20, 20, 400, 400);
System::SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
System::SharedPtr<IChartCategory> cat;
System::ArrayPtr<double> total_for_Cat = System::MakeObject<System::Array<double>>(chart->get_ChartData()->get_Categories()->get_Count(), 0);
for (int32_t k = 0; k < chart->get_ChartData()->get_Categories()->get_Count(); k++)
{
cat = chart->get_ChartData()->get_Categories()->idx_get(k);
for (int32_t i = 0; i < chart->get_ChartData()->get_Series()->get_Count(); i++)
{
total_for_Cat[k] = total_for_Cat[k] + System::Convert::ToDouble(chart->get_ChartData()->get_Series()->idx_get(i)->get_DataPoints()->idx_get(k)->get_Value()->get_Data());
}
}
double dataPontPercent = 0.f;
for (int32_t x = 0; x < chart->get_ChartData()->get_Series()->get_Count(); x++)
{
series = chart->get_ChartData()->get_Series()->idx_get(x);
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowLegendKey(false);
for (int32_t j = 0; j < series->get_DataPoints()->get_Count(); j++)
{
System::SharedPtr<IDataLabel> lbl = series->get_DataPoints()->idx_get(j)->get_Label();
dataPontPercent = (System::Convert::ToDouble(series->get_DataPoints()->idx_get(j)->get_Value()->get_Data()) / total_for_Cat[j]) * 100;
System::SharedPtr<IPortion> port = System::MakeObject<Portion>();
port->set_Text(System::String::Format(u"{0:F2} %", dataPontPercent));
port->get_PortionFormat()->set_FontHeight(8.f);
lbl->get_TextFrameForOverriding()->set_Text(u"");
System::SharedPtr<IParagraph> para = lbl->get_TextFrameForOverriding()->get_Paragraphs()->idx_get(0);
para->get_Portions()->Add(port);
lbl->get_DataLabelFormat()->set_ShowSeriesName(false);
lbl->get_DataLabelFormat()->set_ShowPercentage(false);
lbl->get_DataLabelFormat()->set_ShowLegendKey(false);
lbl->get_DataLabelFormat()->set_ShowCategoryName(false);
lbl->get_DataLabelFormat()->set_ShowBubbleSize(false);
}
}
// Save presentation with chart
// Write the presentation file to disk
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/DoughnutChartHole_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Doughnut, 0, 0, 500, 500);
chart->get_ChartData()->get_SeriesGroups()->idx_get(0)->set_DoughnutHoleSize(90);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String templatePath = u"../templates/presentation.pptx";
const String outPath = u"../out/presentation-out.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<Aspose::Slides::Charts::IChart> chart = System::DynamicCast_noexcept<Aspose::Slides::Charts::IChart>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));
System::SharedPtr<Aspose::Slides::Charts::ChartData> chartData = System::DynamicCast<Aspose::Slides::Charts::ChartData>(chart->get_ChartData());
chartData->get_Series()->idx_get(0)->get_DataPoints()->idx_get(0)->get_Value()->get_AsCell()->set_Value(System::ObjectExt::Box<int32_t>(100));
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/EmbeddedVideoFrame_out.pptx";
const String filePath = u"../templates/Wildlife.mp4";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Load the video file to stream
System::SharedPtr<System::IO::Stream> stream = System::MakeObject<System::IO::FileStream>(filePath, System::IO::FileMode::Open, System::IO::FileAccess::Read);
// Embedd vide inside presentation
System::SharedPtr<IVideo> vid = pres->get_Videos()->AddVideo(stream);
// Add Video Frame
System::SharedPtr<IVideoFrame> vf = slide->get_Shapes()->AddVideoFrame(50, 150, 300, 150, vid);
// Set video to Video Frame
vf->set_EmbeddedVideo(vid);
// Set Play Mode and Volume of the Video
vf->set_PlayMode(VideoPlayModePreset::Auto);
vf->set_Volume(AudioVolumeMode::Loud);
//Write the PPTX file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/EmbedFontsInHtml_out.html";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Add EmbedAllFontsHtmlController
ArrayPtr<String> fontNameExcludeList = MakeArray<String>({ u"Calibri", u"Arial" });
SharedPtr<Aspose::Slides::Export::EmbedAllFontsHtmlController> EmbedFontController = MakeObject <Aspose::Slides::Export::EmbedAllFontsHtmlController>(fontNameExcludeList);
SharedPtr<Aspose::Slides::Export::HtmlOptions> htmlOptions = MakeObject <Aspose::Slides::Export::HtmlOptions>();
htmlOptions->set_HtmlFormatter((HtmlFormatter::CreateCustomFormatter(EmbedFontController)));
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Html, htmlOptions);
// The path to the documents directory.
const String outPath = u"../out/EndParaGraphProperties_out.pptx";
//const String templatePath = u"../templates/DefaultFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 100, 100, 300, 300);
// Add TextFrame to the Rectangle
SharedPtr<ITextFrame> tf = ashp->AddTextFrame(String::Empty);
// Adding the first Paragraph
//SharedPtr<IParagraph> para1 = tf->get_Paragraphs()->idx_get(0);
SharedPtr<Paragraph> para1 = MakeObject<Paragraph>();
SharedPtr<Portion> port01 = MakeObject<Portion>(u"Sample text");
para1->get_Portions()->Add(port01);
// Adding the second Paragraph
SharedPtr<Paragraph> para2 = MakeObject<Paragraph>();
SharedPtr<Portion> port02 = MakeObject<Portion>(u"Sample text 2");
para2->get_Portions()->Add(port02);
SharedPtr<PortionFormat> endParagraphPortionFormat = MakeObject< PortionFormat>();
endParagraphPortionFormat->set_FontHeight ( 48);
endParagraphPortionFormat->set_LatinFont ( MakeObject< FontData>(u"Times New Roman"));
para2->set_EndParagraphPortionFormat(endParagraphPortionFormat);
ashp->get_TextFrame()->get_Paragraphs()->Add(para1);
ashp->get_TextFrame()->get_Paragraphs()->Add(para2);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/ExistingChart.pptx";
const String outPath = u"../out/ExistingChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<Chart> chart = DynamicCast<Aspose::Slides::Charts::Chart>(slide->get_Shapes()->idx_get(0));
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();
// Changing chart Category Name
fact->GetCell(defaultWorksheetIndex, 1, 0, ObjectExt::Box<String>(u"Modified Category 1"));
fact->GetCell(defaultWorksheetIndex, 2, 0, ObjectExt::Box<String>(u"Modified Category 2"));
// Take first chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
// Now updating series data
fact->GetCell(defaultWorksheetIndex, 0, 1, ObjectExt::Box<String>(u"New_Series1"));// Modifying series name
series->get_DataPoints()->idx_get(0)->get_Value()->set_Data(System::ObjectExt::Box<double>(90));
series->get_DataPoints()->idx_get(1)->get_Value()->set_Data(System::ObjectExt::Box<double>(123));
series->get_DataPoints()->idx_get(2)->get_Value()->set_Data(System::ObjectExt::Box<double>(44));
// Take Second chart series
series = chart->get_ChartData()->get_Series()->idx_get(1);
// Now updating series data
fact->GetCell(defaultWorksheetIndex, 0, 2, ObjectExt::Box<System::String>(u"New_Series2"));// Modifying series name
series->get_DataPoints()->idx_get(0)->get_Value()->set_Data(System::ObjectExt::Box<double>(20));
series->get_DataPoints()->idx_get(1)->get_Value()->set_Data(System::ObjectExt::Box<double>(67));
series->get_DataPoints()->idx_get(2)->get_Value()->set_Data(System::ObjectExt::Box<double>(99));
// Now, Adding a new serie
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 3, ObjectExt::Box<System::String>(u"Series 3")), chart->get_Type());
// Take 3rd chart series
series = chart->get_ChartData()->get_Series()->idx_get(2);
// Now populating series data
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 3, ObjectExt::Box<double>(20)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 3, ObjectExt::Box<double>(50)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 3, ObjectExt::Box<double>(30)));
chart->set_Type(Aspose::Slides::Charts::ChartType::ClusteredCylinder);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/";
const String templatePath = u"../templates/Video.pptx";
System::SharedPtr<LoadOptions> loadOptions = System::MakeObject<LoadOptions>();
loadOptions->get_BlobManagementOptions()->set_PresentationLockingBehavior(Aspose::Slides::PresentationLockingBehavior::KeepLocked);
// lock the source file and don't load it into memory
// create the Presentation's instance, lock the "hugePresentationWithAudiosAndVideos.pptx" file.
{
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath, loadOptions);
// Clearing resources under 'using' statement
//System::Details::DisposeGuard __dispose_guard_0{ pres, ASPOSE_CURRENT_FUNCTION };
// ------------------------------------------
// let's save each video to a file. to prevent memory usage we need a buffer which will be used
// to exchange tha data from the presentation's video stream to a stream for newly created video file.
System::ArrayPtr<uint8_t> buffer = System::MakeArray<uint8_t>(8 * 1024, 0);
// iterate through the videos
for (int32_t index = 0; index < pres->get_Videos()->get_Count(); index++)
{
System::SharedPtr<IVideo> video = pres->get_Videos()->idx_get(index);
// open the presentation video stream. Please note that we intentionally avoid accessing properties
// like video.BinaryData - this property returns a byte array containing full video, and that means
// this bytes will be loaded into memory. We will use video.GetStream, which will return Stream and
// that allows us to not load the whole video into memory.
{
System::SharedPtr<System::IO::Stream> presVideoStream = video->GetStream();
// Clearing resources under 'using' statement
//System::Details::DisposeGuard __dispose_guard_1{ presVideoStream, ASPOSE_CURRENT_FUNCTION };
// ------------------------------------------
{
System::SharedPtr<System::IO::FileStream> outputFileStream = System::IO::File::OpenWrite(outPath+System::String::Format(u"video{0}.avi",index));
// Clearing resources under 'using' statement
//System::Details::DisposeGuard __dispose_guard_2{ outputFileStream, ASPOSE_CURRENT_FUNCTION };
// ------------------------------------------
int32_t bytesRead;
while ((bytesRead = presVideoStream->Read(buffer, 0, buffer->get_Length())) > 0)
{
outputFileStream->Write(buffer, 0, bytesRead);
}
}
}
// memory consumption will stay low no matter what size the videos or presentation is.
}
// The path to the documents directory.
const String outPath = u"../out/output.html";
const String tempplatePath = u"../templates/DefaultFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(tempplatePath);
// Acesss the default first slide of presentation
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Desired index
int index = 0;
// Accessing the added shape
SharedPtr<IShape> shape = slide->get_Shapes()->idx_get(0);
SharedPtr<AutoShape> ashape = DynamicCast<Aspose::Slides::AutoShape>(shape);
// Extracting first paragraph as HTML
SharedPtr<System::IO::StreamWriter> sw = MakeObject<System::IO::StreamWriter>(outPath, false, Encoding::get_UTF8());
// System::IO::StreamWriter^ sr = gcnew System::IO::StreamWriter("TestFile.txt", false, Encoding::get_UTF8());
//Writing Paragraphs data to HTML by providing paragraph starting index, total paragraphs to be copied
sw->Write(ashape->get_TextFrame()->get_Paragraphs()->ExportToHtml(0, ashape->get_TextFrame()->get_Paragraphs()->get_Count(), nullptr));
sw->Close();
// The path to the documents directory.
const String templatePath = u"../templates/Media File.pptx";
const String path = u"../out/";
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
const String fileName = u"ExportMediaFiles_out.html";
const String baseUri = u"http://www.example.com/";
SharedPtr<VideoPlayerHtmlController> videoController = MakeObject<VideoPlayerHtmlController>(path, fileName, baseUri);
System::SharedPtr<HtmlOptions> htmlOptions = System::MakeObject<HtmlOptions>(videoController);
System::SharedPtr<SVGOptions> svgOptions = System::MakeObject<SVGOptions>(videoController);
htmlOptions->set_HtmlFormatter(HtmlFormatter::CreateCustomFormatter(videoController));
htmlOptions->set_SlideImageFormat(SlideImageFormat::Svg(svgOptions));
pres->Save(path+fileName, SaveFormat::Html, htmlOptions);
SharedPtr<Presentation> presentation = MakeObject<Presentation>(u"SomePresentation.pptx");
SharedPtr<Aspose::Slides::Export::HtmlOptions> saveOptions = MakeObject <Aspose::Slides::Export::HtmlOptions>();
saveOptions->set_SvgResponsiveLayout(true);
presentation->Save(u"../out/SomePresentation-out.html", Export::SaveFormat::Html, saveOptions);
const String templatePath = u"../templates/TestOlePresentation.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
SharedPtr<ISlide> slide;
SharedPtr<IShape> shape;
for (int slideCount = 0; slideCount < pres->get_Slides()->get_Count(); slideCount++) {
slide = pres->get_Slides()->idx_get(slideCount);
for (int count = 0; count < slide->get_Shapes()->get_Count(); count++) {
shape = slide->get_Shapes()->idx_get(count);
if (System::ObjectExt::Is<OleObjectFrame>(shape)) {
// Cast the shape to OleObjectFrame
SharedPtr<OleObjectFrame> oof = DynamicCast<Aspose::Slides::OleObjectFrame>(shape);
System::ArrayPtr<uint8_t> buffer = oof->get_EmbeddedFileData();
{
String fileExtention = oof->get_EmbeddedFileExtension();
String extractedPath = u"../out/ExtractedObject_out" + fileExtention;
System::SharedPtr<System::IO::FileStream> stream = System::MakeObject<System::IO::FileStream>(extractedPath, System::IO::FileMode::Create, System::IO::FileAccess::Write, System::IO::FileShare::Read);
stream->Flush();
stream->Close();
}
}
}
}
// The path to the documents directory.
const String templatePath = u"../templates/VBA.pptm";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
if (pres->get_VbaProject() != NULL) // check if Presentation contains VBA Project
{
//for (SharedPtr<IVbaModule> module : pres->get_VbaProject()->get_Modules())
for (int i = 0; i < pres->get_VbaProject()->get_Modules()->get_Count(); i++)
{
SharedPtr<IVbaModule> module = pres->get_VbaProject()->get_Modules()->idx_get(i);
System::Console::WriteLine(module->get_Name());
System::Console::WriteLine(module->get_SourceCode());
}
}
// The path to the documents directory.
const String templatePath = u"../templates/Video.pptx";
const String outPath = u"../out/Video_out";
// The path to the documents directory.
System::String dataDir = u"replace_with_the_correct_path";
// Instantiate a Presentation object that represents a presentation file
System::SharedPtr<Presentation> presentation = System::MakeObject<Presentation>(templatePath);
{
auto slide_enumerator = (presentation->get_Slides())->GetEnumerator();
decltype(slide_enumerator->get_Current()) slide;
while (slide_enumerator->MoveNext() && (slide = slide_enumerator->get_Current(), true))
{
auto shape_enumerator = (presentation->get_Slides()->idx_get(0)->get_Shapes())->GetEnumerator();
decltype(shape_enumerator->get_Current()) shape;
while (shape_enumerator->MoveNext() && (shape = shape_enumerator->get_Current(), true))
{
if (System::ObjectExt::Is<VideoFrame>(shape))
{
System::SharedPtr<VideoFrame> vf = System::DynamicCast_noexcept<Aspose::Slides::VideoFrame>(shape);
System::String type = vf->get_EmbeddedVideo()->get_ContentType();
int32_t ss = type.LastIndexOf(L'/');
type = type.Remove(0, type.LastIndexOf(L'/') + 1);
System::ArrayPtr<uint8_t> buffer = vf->get_EmbeddedVideo()->get_BinaryData();
{
System::SharedPtr<System::IO::FileStream> stream = System::MakeObject<System::IO::FileStream>(outPath + type, System::IO::FileMode::Create, System::IO::FileAccess::Write, System::IO::FileShare::Read);
// Clearing resources under 'using' statement
//System::Details::DisposeGuard __dispose_guard_0{ stream, ASPOSE_CURRENT_FUNCTION };
// ------------------------------------------
stream->Write(buffer, 0, buffer->get_Length());
}
}
}
}
}
System::SharedPtr<Presentation> presentation = System::MakeObject<Presentation>();
System::SharedPtr<IFontFallBackRulesCollection> userRulesList = System::MakeObject<FontFallBackRulesCollection>();
userRulesList->Add(System::MakeObject<FontFallBackRule>(static_cast<uint32_t>(0x0B80), static_cast<uint32_t>(0x0BFF), u"Vijaya"));
userRulesList->Add(System::MakeObject<FontFallBackRule>(static_cast<uint32_t>(0x3040), static_cast<uint32_t>(0x309F), u"MS Mincho, MS Gothic"));
presentation->get_FontsManager()->set_FontFallBackRulesCollection(userRulesList);
// The path to the documents directory.
const String outPath = u"../out/FillFormat_SmartArt_ShapeNode_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::ClosedChevronProcess);
// Adding SmartArt node
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArtNode> NewNode = smart->get_AllNodes()->AddNode();
//Adding text to added node
NewNode->get_TextFrame()->set_Text( u"Some text");
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/FillShapesGradient_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Now create effect "PathFootball" for existing shape from scratch.
SharedPtr<IAutoShape> autoShape = slide->get_Shapes()->AddAutoShape(ShapeType::Ellipse, 50, 150, 75, 150);
/*
// Apply some gradiant formatting to ellipse shape
autoShape->get_FillFormat()->set_FillType(FillType::Gradient);
autoShape->get_FillFormat()->get_GradientFormat()->set_GradientShape(GradientShape::Linear);
// Set the Gradient Direction
autoShape->get_FillFormat()->get_GradientFormat()->set_GradientDirection ( GradientDirection::FromCorner2);
// Add two Gradiant Stops
autoShape->get_FillFormat()->get_GradientFormat()->get_GradientStops()->Add((float)1.0, PresetColor::Purple);
autoShape->get_FillFormat()->get_GradientFormat()->get_GradientStops()->Add((float)0, PresetColor::Red);
*/
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path tos the documents directory.
const String outPath = u"../out/FillShapesPattern_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Now create effect "PathFootball" for existing shape from scratch.
SharedPtr<IAutoShape> autoShape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 150, 75, 150);
/*
// Apply some pattern formatting to rectangle shape
autoShape->get_FillFormat()->set_FillType(FillType::Pattern);
autoShape->get_FillFormat()->get_PatternFormat()->set_PatternStyle(PatternStyle::Trellis);
// Set the pattern back and fore colors
autoShape->get_FillFormat()->get_PatternFormat()->get_BackColor()->set_Color ( Color::get_LightGray());
autoShape->get_FillFormat()->get_PatternFormat()->get_ForeColor()->set_Color(Color::get_Yellow());
*/
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path tos the documents directory.
const String outPath = u"../out/FillShapesPicture_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
const String ImagePath = u"../templates/Tulips.jpg";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Now create effect "PathFootball" for existing shape from scratch.
SharedPtr<IAutoShape> autoShape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 150, 75, 150);
// Apply some picture formatting to rectangle shape
autoShape->get_FillFormat()->set_FillType(FillType::Picture);
// Set the picture fill mode
autoShape->get_FillFormat()->get_PictureFillFormat()->set_PictureFillMode(PictureFillMode::Tile);
// Get the picture
auto bitmap = MakeObject<System::Drawing::Bitmap>(ImagePath);
// Add image to presentation's images collection
SharedPtr<IPPImage> imgx = pres->get_Images()->AddImage(bitmap);
//Set picture to shape
autoShape->get_FillFormat()->get_PictureFillFormat()->get_Picture()->set_Image(imgx);
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path tos the documents directory.
const String outPath = u"../out/FillShapeswithSolidColor_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Now create effect "PathFootball" for existing shape from scratch.
SharedPtr<IAutoShape> autoShape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 150, 75, 150);
// Apply some picture formatting to rectangle shape
autoShape->get_FillFormat()->set_FillType(FillType::Solid);
// Set the color of the rectangle
autoShape->get_FillFormat()->get_SolidFillColor()->set_Color( Color::get_Yellow());
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/FindShapeInSlide_out.pptx";
const String templatePath = u"../templates/FindingShapeInSlide.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
SharedPtr<IShape> shape = Aspose::Slides::Util::SlideUtil::FindShape(slide, u"Shape1");
if (shape != nullptr)
{
Console::WriteLine(u"Shape Name: " + shape->get_Name());
Console::WriteLine(u"Shape Alternative Tex: " + shape->get_AlternativeText());
}
// The path to the documents directory.
const String outPath = u"../out/FontFamilySetting_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u" ");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
// Create the Paragraph object for text frame
SharedPtr<IParagraph> paragraph = txtFrame->get_Paragraphs()->idx_get(0);
// Create Portion object for paragraph
SharedPtr<IPortion> portion = paragraph->get_Portions()->idx_get(0);
portion->set_Text(u"Aspose TextBox");
//Get portion format
SharedPtr<IPortionFormat> pf = portion->get_PortionFormat();
// Set the Font for the Portion
pf->set_LatinFont(MakeObject<FontData>(u"Times New Roman"));
// Set Bold property of the Font
pf->set_FontBold (NullableBool::True);
// Set Italic property of the Font
pf->set_FontItalic(NullableBool::True);
// Set Underline property of the Font
pf->set_FontUnderline(TextUnderlineType::Single);
// Set the Height of the Font
pf->set_FontHeight (25);
// Set the color of the Font
pf->get_FillFormat()->set_FillType(FillType::Solid);
pf->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Blue());
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/FontProperties_out.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing the first and second placeholder in the slide and typecasting it as AutoShape
SharedPtr<IShape> shape1 = slide->get_Shapes()->idx_get(0);
SharedPtr<IShape> shape2 = slide->get_Shapes()->idx_get(1);
SharedPtr<AutoShape> ashp1 = DynamicCast<Aspose::Slides::AutoShape>(shape1);
SharedPtr<AutoShape> ashp2 = DynamicCast<Aspose::Slides::AutoShape>(shape2);
SharedPtr<ITextFrame> tf1 = ashp1->get_TextFrame();
SharedPtr<ITextFrame> tf2 = ashp2->get_TextFrame();
// Accessing the first Paragraph
SharedPtr<IParagraph> para1 = tf1->get_Paragraphs()->idx_get(0);
SharedPtr<IParagraph> para2 = tf2->get_Paragraphs()->idx_get(0);
// Accessing the first portion
SharedPtr<IPortion> port1 = para1->get_Portions()->idx_get(0);
SharedPtr<IPortion> port2 = para2->get_Portions()->idx_get(0);
// Define new fonts
SharedPtr<FontData> fd1 = MakeObject<FontData>(u"Elephant");
SharedPtr<FontData> fd2 = MakeObject<FontData>(u"Castellar");
// Assign new fonts to portion
port1->get_PortionFormat()->set_LatinFont ( fd1);
port2->get_PortionFormat()->set_LatinFont(fd2);
// Set font to Bold
port1->get_PortionFormat()->set_FontBold ( NullableBool::True);
port2->get_PortionFormat()->set_FontBold ( NullableBool::True);
// Set font to Italic
port1->get_PortionFormat()->set_FontItalic( NullableBool::True);
port2->get_PortionFormat()->set_FontItalic ( NullableBool::True);
// Set font color
port1->get_PortionFormat()->get_FillFormat()->set_FillType ( FillType::Solid);
port1->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color ( Color::get_Purple());
port2->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
port2->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Peru());
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/FontPropertiesForChart.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
SharedPtr<IChart> chart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 100, 100, 500, 400);
chart->get_TextFormat()->get_PortionFormat()->set_FontHeight(20);
chart->get_ChartData()->get_Series()->idx_get(0)->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/FormatJoinStyles_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> shape1 = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 150, 150, 75);
SharedPtr<IAutoShape> shape2 = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 300, 100, 150, 75);
SharedPtr<IAutoShape> shape3 = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 250, 150, 75);
// Set the fill color of the rectangle shape
shape1->get_FillFormat()->set_FillType(FillType::Solid);
shape1->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
shape1->get_LineFormat()->set_Width(15);
shape1->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid);
shape1->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Blue());
// Set the fill color of the rectangle shape
shape2->get_FillFormat()->set_FillType(FillType::Solid);
shape2->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
shape2->get_LineFormat()->set_Width(15);
shape2->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid);
shape2->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Blue());
// Set the fill color of the rectangle shape
shape3->get_FillFormat()->set_FillType(FillType::Solid);
shape3->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
shape3->get_LineFormat()->set_Width(15);
shape3->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid);
shape3->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Blue());
// Set the Join Style
shape2->get_LineFormat()->set_JoinStyle(LineJoinStyle::Miter);
shape2->get_LineFormat()->set_JoinStyle(LineJoinStyle::Bevel);
shape3->get_LineFormat()->set_JoinStyle(LineJoinStyle::Round);
// Add text to each rectangle
shape1->get_TextFrame()->set_Text(u"This is Miter Join Style");
shape2->get_TextFrame()->set_Text(u"This is Bevel Join Style");
shape3->get_TextFrame()->set_Text(u"This is Round Join Style");
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/FormatLines_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::Rectangle, 50, 150, 150, 75);
// Set the fill color of the rectangle shape
shape->get_FillFormat()->set_FillType(FillType::Solid);
shape->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_White());
// Apply some formatting on the line
shape->get_LineFormat()->set_Style(LineStyle::ThickThin);
shape->get_LineFormat()->set_Width(7);
shape->get_LineFormat()->set_DashStyle(LineDashStyle::Dash);
shape->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid);
shape->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Blue());
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/FormattedEllipse_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::Ellipse, 50, 150, 150, 50);
// Set the fill color of the rectangle shape
shape->get_FillFormat()->set_FillType(FillType::Solid);
shape->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Chocolate());
// Apply some formatting on the line
shape->get_LineFormat()->set_Style(LineStyle::ThickThin);
shape->get_LineFormat()->set_Width(5);
shape->get_LineFormat()->set_DashStyle(LineDashStyle::DashDot);
shape->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid);
shape->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/FormattedRectangle_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::Rectangle, 50, 150, 150, 75);
// Set the fill color of the rectangle shape
shape->get_FillFormat()->set_FillType(FillType::Solid);
shape->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_White());
// Apply some formatting on the line
shape->get_LineFormat()->set_Style(LineStyle::ThickThin);
shape->get_LineFormat()->set_Width(7);
shape->get_LineFormat()->set_DashStyle(LineDashStyle::Dash);
shape->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid);
shape->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Blue());
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
/*class CustomSvgShapeFormattingController::ISvgShapeFormattingController
{
void CustomSvgShapeFormattingController()
{
public:
int m_shapeIndex;
CustomSvgShapeFormattingController(int shapeStartIndex = 0)
{
m_shapeIndex = shapeStartIndex;
}
public void FormatShape(ISvgShape svgShape, IShape shape)
{
svgShape.Id = string.Format("shape-{0}", m_shapeIndex++);
}
};
};
*/
void GeneratingSVGWithCustomShapeIDS()
{
// The path to the documents directory.
const String templatePath = L"../templates/TestDeck_050.pptx";
const String outPath = L"../out/GeneratingSVGWithCustomShapeIDS_out.svg";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
SharedPtr<SVGOptions> svgOptions = MakeObject< SVGOptions>();
SharedPtr<CustomSvgShapeFormattingController>customSvgShapeFormattingController = MakeSharedPtr<CustomSvgShapeFormattingController>(0);
svgOptions->set_ShapeFormattingController(customSvgShapeFormattingController);
// Access the first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Create a memory stream object
SharedPtr<System::IO::MemoryStream> SvgStream = MakeObject<System::IO::MemoryStream>();
// Generate SVG image of slide and save in memory stream
slide->WriteAsSvg(SvgStream);
SvgStream->set_Position(0);
// Save memory stream to file
try
{
System::SharedPtr<System::IO::Stream> fileStream = System::IO::File::OpenWrite(outPath);
// Clearing resources under 'using' statement
System::Details::DisposeGuard __dispose_guard_1{ fileStream, ASPOSE_CURRENT_FUNCTION };
// ------------------------------------------
System::ArrayPtr<uint8_t> buffer = System::MakeObject<System::Array<uint8_t>>(8 * 1024, 0);
int32_t len;
while ((len = SvgStream->Read(buffer, 0, buffer->get_Length())) > 0)
{
fileStream->Write(buffer, 0, len);
}
}
catch (Exception e)
{
}
SvgStream->Close();
}
const String templatePath = u"../templates/SamplePresentation.pptx";
auto pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<IBackgroundEffectiveData> effBackground = pres->get_Slides()->idx_get(0)->CreateBackgroundEffective();
if (effBackground->get_FillFormat()->get_FillType() == Aspose::Slides::FillType::Solid)
{
System::Console::WriteLine(System::String(u"Fill color: ") + effBackground->get_FillFormat()->get_SolidFillColor());
}
else
{
System::Console::WriteLine(System::String(u"Fill type: ") + System::ObjectExt::ToString(effBackground->get_FillFormat()->get_FillType()));
}
// The path to the documents directory.
const String templatePath = u"../templates/Presentation1.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<IThreeDFormatEffectiveData> threeDEffectiveData = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)->get_ThreeDFormat()->GetEffective();
System::Console::WriteLine(u"= Effective camera properties =");
System::Console::WriteLine(System::String(u"Type: ") + System::ObjectExt::ToString((int)threeDEffectiveData->get_Camera()->get_CameraType()));
System::Console::WriteLine(System::String(u"Field of view: ") + threeDEffectiveData->get_Camera()->get_FieldOfViewAngle());
System::Console::WriteLine(System::String(u"Zoom: ") + threeDEffectiveData->get_Camera()->get_Zoom());
// The path to the documents directory.
const String outPath = u"../out/ChartImage_out.png";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
//Generate chart image
auto bitmap = chart->GetThumbnail();
bitmap->Save(outPath, ImageFormat::get_Png());
// The path to the documents directory.
const String templatePath = u"../templates/Presentation1.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<IAutoShape> shape = System::DynamicCast_noexcept<Aspose::Slides::IAutoShape>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));
System::SharedPtr<ITextFrameFormat> localTextFrameFormat = shape->get_TextFrame()->get_TextFrameFormat();
System::SharedPtr<ITextFrameFormatEffectiveData> effectiveTextFrameFormat = localTextFrameFormat->GetEffective();
System::SharedPtr<IPortionFormat> localPortionFormat = shape->get_TextFrame()->get_Paragraphs()->idx_get(0)->get_Portions()->idx_get(0)->get_PortionFormat();
System::SharedPtr<IPortionFormatEffectiveData> effectivePortionFormat = localPortionFormat->GetEffective();
// The path to the documents directory.
const String templatePath = u"../templates/Presentation1.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<ITable> tbl = System::DynamicCast_noexcept<Aspose::Slides::ITable>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));
System::SharedPtr<ITableFormatEffectiveData> tableFormatEffective = tbl->get_TableFormat()->GetEffective();
System::SharedPtr<IRowFormatEffectiveData> rowFormatEffective = tbl->get_Rows()->idx_get(0)->get_RowFormat()->GetEffective();
System::SharedPtr<IColumnFormatEffectiveData> columnFormatEffective = tbl->get_Columns()->idx_get(0)->get_ColumnFormat()->GetEffective();
System::SharedPtr<ICellFormatEffectiveData> cellFormatEffective = tbl->idx_get(0, 0)->get_CellFormat()->GetEffective();
System::SharedPtr<IFillFormatEffectiveData> tableFillFormatEffective = tableFormatEffective->get_FillFormat();
System::SharedPtr<IFillFormatEffectiveData> rowFillFormatEffective = rowFormatEffective->get_FillFormat();
System::SharedPtr<IFillFormatEffectiveData> columnFillFormatEffective = columnFormatEffective->get_FillFormat();
System::SharedPtr<IFillFormatEffectiveData> cellFillFormatEffective = cellFormatEffective->get_FillFormat();
// The path to the documents directory.
const String templatePath = u"../templates/Para Effects.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
SharedPtr<ISequence> sequence = slide->get_Timeline()->get_MainSequence();
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Accessing second shape from slide.
SharedPtr<IShape> shape = slide->get_Shapes()->idx_get(1);
SharedPtr<AutoShape> ashp = DynamicCast<Aspose::Slides::AutoShape>(shape);
for (int i = 0; i < ashp->get_TextFrame()->get_Paragraphs()->get_Count(); i++)
{
SharedPtr<IParagraph> para = ashp->get_TextFrame()->get_Paragraphs()->idx_get(i);
System::ArrayPtr<SharedPtr<IEffect>> effects = sequence->GetEffectsByParagraph(para);
if (effects->get_Count() > 0)
{
System::Console::WriteLine(u"Paragraph = " + para->get_Text()+u" has "+ effects[0]->GetType()+ u" effect.");
}
}
const String templatePath = u"../templates/AccessSlides.pptx";
SharedPtr<IPresentationInfo> info = PresentationFactory::get_Instance()->GetPresentationInfo(templatePath);
switch (info->get_LoadFormat())
{
case LoadFormat::Pptx:
{
break;
}
case LoadFormat::Unknown:
{
break;
}
}
// The path to the documents directory.
//The following line shall return folders where font files are searched.
//Those are folders that have been added with LoadExternalFonts method as well as system font folders.
ArrayPtr<String>fontFolders=FontsLoader::GetFontFolders();
// The path to the documents directory.
const String templatePath = u"../templates/Presentation1.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<IThreeDFormatEffectiveData> threeDEffectiveData = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)->get_ThreeDFormat()->GetEffective();
System::Console::WriteLine(u"= Effective light rig properties =");
System::Console::WriteLine(System::String(u"Type: ") + System::ObjectExt::ToString((int)threeDEffectiveData->get_LightRig()->get_LightType()));
System::Console::WriteLine(System::String(u"Direction: ") + System::ObjectExt::ToString((int)threeDEffectiveData->get_LightRig()->get_Direction()));
// The path to the documents directory.
const String templatePath = u"../templates/Presentation1.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<IThreeDFormatEffectiveData> threeDEffectiveData = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)->get_ThreeDFormat()->GetEffective();
System::Console::WriteLine(u"= Effective shape's top face relief properties =");
System::Console::WriteLine(System::String(u"Type: ") + System::ObjectExt::ToString((int)threeDEffectiveData->get_BevelTop()->get_BevelType()));
System::Console::WriteLine(System::String(u"Width: ") + threeDEffectiveData->get_BevelTop()->get_Width());
System::Console::WriteLine(System::String(u"Height: ") + threeDEffectiveData->get_BevelTop()->get_Height());
// The path to the documents directory.
const String templatePath = u"../templates/Presentation1.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<IAutoShape> shape = System::DynamicCast_noexcept<Aspose::Slides::IAutoShape>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));
System::SharedPtr<ITextFrameFormatEffectiveData> effectiveTextFrameFormat = shape->get_TextFrame()->get_TextFrameFormat()->GetEffective();
System::Console::WriteLine(System::String(u"Anchoring type: ") + System::ObjectExt::ToString((int)effectiveTextFrameFormat->get_AnchoringType()));
System::Console::WriteLine(System::String(u"Autofit type: ") + System::ObjectExt::ToString((int)effectiveTextFrameFormat->get_AutofitType()));
System::Console::WriteLine(System::String(u"Text vertical type: ") + System::ObjectExt::ToString((int)effectiveTextFrameFormat->get_TextVerticalType()));
System::Console::WriteLine(u"Margins");
System::Console::WriteLine(System::String(u" Left: ") + effectiveTextFrameFormat->get_MarginLeft());
System::Console::WriteLine(System::String(u" Top: ") + effectiveTextFrameFormat->get_MarginTop());
System::Console::WriteLine(System::String(u" Right: ") + effectiveTextFrameFormat->get_MarginRight());
System::Console::WriteLine(System::String(u" Bottom: ") + effectiveTextFrameFormat->get_MarginBottom());
// The path to the documents directory.
const String templatePath = u"../templates/SmartArt.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Traverse through every shape inside first slide
//foreach(IShape shape in pres.Slides[0].Shapes)
for (int x = 0; x<pres->get_Slides()->idx_get(0)->get_Shapes()->get_Count(); x++)
{
SharedPtr<IShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(x);
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape))
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArt> smart = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArt>(shape);
// Traverse through all nodes inside SmartArt
for (int i = 0; i < smart->get_AllNodes()->get_Count(); i++)
{
// Accessing SmartArt node at index i
System::SharedPtr<Aspose::Slides::SmartArt::SmartArtNode> node = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtNode>(smart->get_AllNodes()->idx_get(i));
int iNodeShapeCount = node->get_Shapes()->get_Count();
for(int j=0; j < iNodeShapeCount;j++)
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArtShape> nodeShape=System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtShape>(node->get_Shapes()->idx_get(j));
//auto nodeShape = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtShape>(node->get_Shapes()->idx_get(j));
if (nodeShape->get_TextFrame() != NULL)
{
// Printing the SmartArt nodeShape parameters
System::Console::WriteLine(u"NodeShape Text is: {0}", nodeShape->get_TextFrame()->get_Text());
}
}
}
}
}
// The path to the documents directory.
const String templatePath = u"../templates/Presentation1.pptx";
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
System::SharedPtr<IAutoShape> shape = System::DynamicCast_noexcept<Aspose::Slides::IAutoShape>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));
System::SharedPtr<ITextStyleEffectiveData> effectiveTextStyle = shape->get_TextFrame()->get_TextFrameFormat()->get_TextStyle()->GetEffective();
for (int32_t i = 0; i <= 8; i++)
{
System::SharedPtr<IParagraphFormatEffectiveData> effectiveStyleLevel = effectiveTextStyle->GetLevel(i);
System::Console::WriteLine(System::String(u"= Effective paragraph formatting for style level #") + i + u" =");
System::Console::WriteLine(System::String(u"Depth: ") + effectiveStyleLevel->get_Depth());
System::Console::WriteLine(System::String(u"Indent: ") + effectiveStyleLevel->get_Indent());
System::Console::WriteLine(System::String(u"Alignment: ") + System::ObjectExt::ToString(effectiveStyleLevel->get_Alignment()));
System::Console::WriteLine(System::String(u"Font alignment: ") + System::ObjectExt::ToString(effectiveStyleLevel->get_FontAlignment()));
}
// The path to the documents directory.
const String outPath = u"../out/HandoutHeaderFooterManager_out.pptx";
SharedPtr<Presentation> presentation = MakeObject<Presentation>();
System::SharedPtr<IMasterHandoutSlide> masterHandoutSlide = presentation->get_MasterHandoutSlideManager()->get_MasterHandoutSlide();
if (masterHandoutSlide != nullptr)
{
System::SharedPtr<IBaseHandoutNotesSlideHeaderFooterManag> headerFooterManager = masterHandoutSlide->get_HeaderFooterManager();
if (!headerFooterManager->get_IsHeaderVisible())
headerFooterManager->SetHeaderVisibility(true); // make the master handout slide Header placeholder visible
if (!headerFooterManager->get_IsFooterVisible())
headerFooterManager->SetFooterVisibility(true); // make the master handout slide Footer placeholder visible
if (!headerFooterManager->get_IsSlideNumberVisible())
headerFooterManager->SetSlideNumberVisibility(true); // make the master handout slide SlideNumber placeholder visible
if (!headerFooterManager->get_IsDateTimeVisible())
headerFooterManager->SetDateTimeVisibility(true); // make the master handout slide Date-time placeholder visible
headerFooterManager->SetHeaderText(u"New header text"); // set text to master handout slide Header placeholder
headerFooterManager->SetFooterText(u"New footer text"); // set text to master handout slide Footer placeholder
headerFooterManager->SetDateTimeText(u"New date and time text"); // set master handout to notes slide Date-time placeholder
}
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/HeaderFooterManager_out.pptx";
SharedPtr<Presentation> presentation = MakeObject<Presentation>();
// Instantiate SlideCollection calss
SharedPtr<ISlideCollection> slds = presentation->get_Slides();
// SharedPtr<IBaseSlideHeaderFooterManager> headerFooterManager = presentation->get_Slides()->idx_get(0)->get_HeaderFooterManager();
SharedPtr<IMasterSlideHeaderFooterManager> headerFooterManager = presentation->get_Masters()->idx_get(0)->get_HeaderFooterManager();
if (!headerFooterManager->get_IsFooterVisible()) // Property IsFooterVisible is used for indicating that a slide footer placeholder is not present.
{
headerFooterManager->SetFooterVisibility(true); // Method SetFooterVisibility is used for making a slide footer placeholder visible.
}
if (!headerFooterManager->get_IsSlideNumberVisible()) // Property IsSlideNumberVisible is used for indicating that a slide page number placeholder is not present.
{
headerFooterManager->SetSlideNumberVisibility(true); // Method SetSlideNumberVisibility is used for making a slide page number placeholder visible.
}
if (!headerFooterManager->get_IsDateTimeVisible()) // Property IsDateTimeVisible is used for indicating that a slide date-time placeholder is not present.
{
headerFooterManager->SetDateTimeVisibility(true); // Method SetFooterVisibility is used for making a slide date-time placeholder visible.
}
headerFooterManager->SetFooterText(u"Footer text"); // Method SetFooterText is used for setting text to slide footer placeholder.
headerFooterManager->SetDateTimeText(u"Date and time text"); // Method SetDateTimeText is used for setting text to slide date-time placeholder.
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/HideInformationFromChart.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
SharedPtr<IChart> chart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddChart(ChartType::LineWithMarkers, 140, 118, 320, 370);
//Hiding chart Title
chart->set_HasTitle(false);
///Hiding Values axis
chart->get_Axes()->get_VerticalAxis()->set_IsVisible(false);
//Category Axis visibility
chart->get_Axes()->get_HorizontalAxis()->set_IsVisible(false);
//Hiding Legend
chart->set_HasLegend(false);
//Hiding MajorGridLines
chart->get_Axes()->get_HorizontalAxis()->get_MajorGridLinesFormat()->get_Line()->get_FillFormat()->set_FillType(FillType::NoFill);
for (int i = 0; i < chart->get_ChartData()->get_Series()->get_Count(); i++)
{
chart->get_ChartData()->get_Series()->RemoveAt(i);
}
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
series->get_Marker()->set_Symbol(MarkerStyleType::Circle);
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true);
series->get_Labels()->get_DefaultDataLabelFormat()->set_Position(LegendDataLabelPosition::Top);
series->get_Marker()->set_Size(15);
//Setting series line color
series->get_Format()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid);
series->get_Format()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Magenta());
series->get_Format()->get_Line()->set_DashStyle(LineDashStyle::Solid);
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/Hidingshapes_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Now create effect "PathFootball" for existing shape from scratch.
SharedPtr<IAutoShape> autoShape1 = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 40, 150, 50);
SharedPtr<IAutoShape> autoShape2 = slide->get_Shapes()->AddAutoShape(ShapeType::Moon, 160, 40, 150, 50);
String alttext = u"User Defined";
int iCount = slide->get_Shapes()->get_Count();
for (int i = 0; i < iCount; i++)
{
// Accessing the added shape
SharedPtr<AutoShape> ashape = DynamicCast<Aspose::Slides::AutoShape>(slide->get_Shapes()->idx_get(i));
if (String::Compare(ashape->get_AlternativeText(), alttext, StringComparison::Ordinal) == 0)
{
ashape->set_Hidden(true);
}
}
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
System::SharedPtr<Presentation> presentation = System::MakeObject<Presentation>(u"SomePresentation.pptx");
// highlighting all words 'important'
(System::DynamicCast<Aspose::Slides::AutoShape> (presentation->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)))->get_TextFrame()->HighlightText(u"important", System::Drawing::Color::get_LightBlue());
auto options = System::MakeObject<TextHighlightingOptions>();
options->set_WholeWordsOnly(true);
// highlighting all separate 'the' occurrences
(System::DynamicCast <Aspose::Slides::AutoShape>(presentation->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)))->get_TextFrame()->HighlightText(u"the", System::Drawing::Color::get_Violet(), options);
presentation->Save(u"../out/SomePresentation-out.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
System::SharedPtr<Presentation> presentation = System::MakeObject<Presentation>(u"SomePresentation.pptx");
System::SharedPtr <TextHighlightingOptions> options = System::MakeObject<TextHighlightingOptions>();
// highlighting all words with 10 symbols or longer
(System::DynamicCast <Aspose::Slides::AutoShape>(presentation->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)))->get_TextFrame()->HighlightRegex(u"\\b[^\\s]{10,}\\b", System::Drawing::Color::get_LightGoldenrodYellow(), options);
presentation->Save(u"../out/SomePresentation-out.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ImportingHTMLText_out.pptx";
const String sampleHtml = u"../templates/file.html";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 10, 10, 700, 500);
//Resetting default fill color
ashp->get_FillFormat()->set_FillType(FillType::NoFill);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u" ");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
//GetParagraphs collection
SharedPtr<Aspose::Slides::IParagraphCollection>ParaCollection = txtFrame->get_Paragraphs();
// Clearing all paragraphs in added text frame
ParaCollection->Clear();
// Loading the HTML file using stream reader
SharedPtr<System::IO::StreamReader> tr = MakeObject<System::IO::StreamReader>(sampleHtml);
// Adding text from HTML stream reader in text frame
ParaCollection->AddFromHtml(tr->ReadToEnd());
// Create the Paragraph object for text frame
SharedPtr<IParagraph> paragraph = txtFrame->get_Paragraphs()->idx_get(0);
// Create Portion object for paragraph
SharedPtr<IPortion> portion = paragraph->get_Portions()->idx_get(0);
portion->set_Text(u"Aspose TextBox");
//Get portion format
SharedPtr<IPortionFormat> pf = portion->get_PortionFormat();
// Set the Font for the Portion
pf->set_LatinFont(MakeObject<FontData>(u"Times New Roman"));
// Set Bold property of the Font
pf->set_FontBold(NullableBool::True);
// Set Italic property of the Font
pf->set_FontItalic(NullableBool::True);
// Set Underline property of the Font
pf->set_FontUnderline(TextUnderlineType::Single);
// Set the Height of the Font
pf->set_FontHeight(25);
// Set the color of the Font
pf->get_FillFormat()->set_FillType(FillType::Solid);
pf->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Blue());
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/InsertSvgIntoPresentation_out.pptx";
const String filePath = u"../templates/sample.svg";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
auto svgContent = File::ReadAllText(filePath);
SharedPtr<ISvgImage> svgImage = MakeObject<SvgImage>(svgContent);
SharedPtr<IPPImage> imgx = pres->get_Images()->AddImage(svgImage);
//Adding picture frame with EMZ image
auto m = slide->get_Shapes()->AddPictureFrame(ShapeType::Rectangle, 0, 0, pres->get_SlideSize()->get_Size().get_Width(), pres->get_SlideSize()->get_Size().get_Height(), imgx);
//Write the PPTX file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/FindShapeInSlide_out.pptx";
const String templatePath = u"../templates/FindingShapeInSlide.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
long officeInteropShapeId = 0;
// Getting unique shape identifier in slide scope
// officeInteropShapeId = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)->get_OfficeInteropShapeId();
Console::WriteLine(u"Office Interop Shape ID: " + officeInteropShapeId);
// The path to the documents directory.
const String outPath = u"../out/LineSpacing_out.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing the first and second placeholder in the slide and typecasting it as AutoShape
SharedPtr<ITextFrame> tf1 = (DynamicCast<Aspose::Slides::AutoShape>(slide->get_Shapes()->idx_get(0)))->get_TextFrame();
// Accessing the first Paragraph
SharedPtr<IParagraph> para1 = tf1->get_Paragraphs()->idx_get(0);
// Set properties of Paragraph
para1->get_ParagraphFormat()->set_SpaceWithin ( 80);
para1->get_ParagraphFormat()->set_SpaceBefore ( 40);
para1->get_ParagraphFormat()->set_SpaceAfter ( 40);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
class LinkAllFontsHtmlController : public Aspose::Slides::Export::EmbedAllFontsHtmlController
{
typedef LinkAllFontsHtmlController ThisType;
typedef Aspose::Slides::Export::EmbedAllFontsHtmlController BaseType;
typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
RTTI_INFO_DECL();
public:
LinkAllFontsHtmlController(System::ArrayPtr<System::String> fontNameExcludeList, System::String basePath);
virtual void WriteFont(System::SharedPtr<Aspose::Slides::Export::IHtmlGenerator> generator, System::SharedPtr<IFontData> originalFont, System::SharedPtr<IFontData> substitutedFont, System::String fontStyle, System::String fontWeight, System::ArrayPtr<uint8_t> fontData);
private:
System::String m_basePath;
};
const String templatePath = u"../templates/AccessSlides.pptx";
bool isOldFormat = PresentationFactory::get_Instance()->GetPresentationInfo(templatePath)->get_LoadFormat() == LoadFormat::Ppt95;
const String templatePath = u"../templates/pres.pptx";
const String outPath = u"../out/LockAspectRatio_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
SharedPtr<ITable> table = DynamicCast<ITable>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0)) ;
System::Console::WriteLine(u"Lock aspect ratio set: " + table->get_GraphicalObjectLock()->get_AspectRatioLocked());
table->get_GraphicalObjectLock()->set_AspectRatioLocked(!table->get_GraphicalObjectLock()->get_AspectRatioLocked()); // invert
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ManageEmbeddedFonts_out.pptx";
const String templatePath = u"../templates/EmbeddedFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// render a slide that contains a text frame that uses embedded "FunSized"
slide->GetThumbnail(1,1)->Save(u"../out/picture1_out.png", System::Drawing::Imaging::ImageFormat::get_Png());
SharedPtr<IFontsManager> fontsManager = pres->get_FontsManager();
// get all embedded fonts
ArrayPtr<SharedPtr<IFontData>>embeddedFonts = fontsManager->GetEmbeddedFonts();
SharedPtr<IFontData> data = MakeObject<FontData>(u"Calibri");
SharedPtr<IFontData> funSizedEmbeddedFont = MakeObject<FontData>(u"Calibri");
// find "Calibri" font
auto enumerator_0 =embeddedFonts->GetEnumerator();
decltype(enumerator_0->get_Current()) font_0= enumerator_0->get_Current();
while (enumerator_0->MoveNext() && (font_0 = enumerator_0->get_Current(), true))
{
if (font_0->get_FontName() == data->get_FontName())
{
funSizedEmbeddedFont = font_0;
break;
}
}
// remove "Calibri" font
fontsManager->RemoveEmbeddedFont(funSizedEmbeddedFont);
// render the presentation; removed "Calibri" font is replaced to an existing one
slide->GetThumbnail(1,1)->Save(u"../out/picture2_out.png", System::Drawing::Imaging::ImageFormat::get_Png());
// save the presentation without embedded "Calibri" font
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = L"../templates/Video.pptx";
const String outPath = L"../out/Video_out";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access the first slide
SharedPtr<ISlideCollection> slides = pres->get_Slides()->idx_get(0);
// Create a memory stream object
SharedPtr<System::IO::MemoryStream> SvgStream = MakeObject<System::IO::MemoryStream>();
for(int i=0;i< slides->get_Count();i++)
{
SharedPtr<ISlide> slide =slides->idx_get(i);
for(int j=0;j<slide->get_Shapes()->get_Count();j++)
{
SharedPtr<IShape> shape = slide->get_Shapes()->idx_get(j);
//auto smart = DynamicCast<Aspose::Slides::SmartArt::SmartArt>(pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(0));
if (shape->GetType()==Aspose::Slides::VideoFrame)
{
auto vf = DynamicCast<Aspose::Slides::IVideoFrame>(shape);
String type = vf->get_EmbeddedVideo()->get_ContentType();
int ss = type->get_LastIndexOf('/');
type = type.Remove(0, type.LastIndexOf('/') + 1);
Byte[] buffer = vf.EmbeddedVideo.BinaryData;
using (FileStream stream = new FileStream(dataDir + "NewVideo_out." + type, FileMode.Create, FileAccess.Write, FileShare.Read))
{
stream.Write(buffer, 0, buffer.Length);
}
}
}
}
// The path to the documents directory.
const String outPath = L"../out/SetPDFPageSize_out.pptx";
// Instantiate Presentation class
SharedPtr<Presentation>pres = MakeObject<Presentation>();
// Set SlideSize.Type Property
pres->get_SlideSize()->set_Type(SlideSizeType::A4Paper);
// Set different properties of PDF Options
Aspose::Slides::Export::PdfOptions opts = Aspose::Slides::Export::PdfOptions();
opts.set_SufficientResolution(600);
// Save presentation to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pdf, &opts);
// The path to the documents directory.
const String outPath = u"../out/ManageParagraphFontProperties_out.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing the first and second placeholder in the slide and typecasting it as AutoShape
SharedPtr<IShape> shape1 = slide->get_Shapes()->idx_get(0);
SharedPtr<IShape> shape2 = slide->get_Shapes()->idx_get(1);
SharedPtr<AutoShape> ashp1 = DynamicCast<Aspose::Slides::AutoShape>(shape1);
SharedPtr<AutoShape> ashp2 = DynamicCast<Aspose::Slides::AutoShape>(shape2);
SharedPtr<ITextFrame> tf1 = ashp1->get_TextFrame();
SharedPtr<ITextFrame> tf2 = ashp2->get_TextFrame();
// Accessing the first Paragraph
SharedPtr<IParagraph> para1 = tf1->get_Paragraphs()->idx_get(0);
SharedPtr<IParagraph> para2 = tf2->get_Paragraphs()->idx_get(0);
// Justify the paragraph
para2->get_ParagraphFormat()->set_Alignment (TextAlignment::JustifyLow);
// Accessing the first portion
SharedPtr<IPortion> port1 = para1->get_Portions()->idx_get(0);
SharedPtr<IPortion> port2 = para2->get_Portions()->idx_get(0);
// Define new fonts
SharedPtr<IFontData> fd1 = MakeObject<FontData>(u"Elephant");
SharedPtr<IFontData> fd2 = MakeObject<FontData>(u"Castellar");
// Assign new fonts to portion
port1->get_PortionFormat()->set_LatinFont(fd1);
port2->get_PortionFormat()->set_LatinFont(fd2);
// Set font to Bold
port1->get_PortionFormat()->set_FontBold(NullableBool::True);
port2->get_PortionFormat()->set_FontBold(NullableBool::True);
// Set font to Italic
port1->get_PortionFormat()->set_FontItalic(NullableBool::True);
port2->get_PortionFormat()->set_FontItalic(NullableBool::True);
// Set font color
port1->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
port1->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Purple());
port2->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
port2->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Peru());
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ManageParagraphPictureBulletsInPPT_out.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
const String ImagePath = u"../templates/Tulips.jpg";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u"");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
// Create the Paragraph object for text frame
SharedPtr<IParagraph> paragraph = txtFrame->get_Paragraphs()->idx_get(0);
// Create Portion object for paragraph
SharedPtr<IPortion> portion = paragraph->get_Portions()->idx_get(0);
portion->set_Text(u"Welcome to Aspose.Slides");
// Get the picture
auto bitmap = MakeObject<System::Drawing::Bitmap>(ImagePath);
// Add image to presentation's images collection
SharedPtr<IPPImage> ippxImage = pres->get_Images()->AddImage(bitmap);
// Setting paragraph bullet style and image
paragraph->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Picture);
paragraph->get_ParagraphFormat()->get_Bullet()->get_Picture()->set_Image(ippxImage);
// Setting Bullet Height
paragraph->get_ParagraphFormat()->get_Bullet()->set_Height ( 100);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>();
pres->get_ViewProperties()->get_NormalViewProperties()->set_HorizontalBarState(Aspose::Slides::SplitterBarStateType::Restored);
pres->get_ViewProperties()->get_NormalViewProperties()->set_VerticalBarState(Aspose::Slides::SplitterBarStateType::Maximized);
pres->get_ViewProperties()->get_NormalViewProperties()->get_RestoredTop()->set_AutoAdjust(true);
pres->get_ViewProperties()->get_NormalViewProperties()->get_RestoredTop()->set_DimensionSize(80.0f);
pres->get_ViewProperties()->get_NormalViewProperties()->set_ShowOutlineIcons(true);
pres->Save(u"../out/presentation.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ManagePropertiesCharts_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::StackedColumn3D, 0, 0, 500, 500);
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();
// Now, Adding a new series
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 1, ObjectExt::Box<System::String>(u"Series 1")), chart->get_Type());
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 2, ObjectExt::Box<System::String>(u"Series 2")), chart->get_Type());
// Add Catrgories
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 1, 0, ObjectExt::Box<System::String>(u"Caetegoty 1")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 2, 0, ObjectExt::Box<System::String>(u"Caetegoty 2")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 3, 0, ObjectExt::Box<System::String>(u"Caetegoty 3")));
// Set Rotation3D properties
chart->get_Rotation3D()->set_RightAngleAxes(true);
chart->get_Rotation3D()->set_RotationX ( 40);
chart->get_Rotation3D()->set_RotationY ( 270);
chart->get_Rotation3D()->set_DepthPercents ( 150);
// Take second chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(1);
// Now populating series data
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 1, ObjectExt::Box<double>(20)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 1, ObjectExt::Box<double>(50)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 1, ObjectExt::Box<double>(30)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 2, ObjectExt::Box<double>(30)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 2, ObjectExt::Box<double>(10)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 2, ObjectExt::Box<double>(60)));
// Set OverLap value
series->get_ParentSeriesGroup()->set_Overlap ( 100);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/SimpleSlideTransitions.pptx";
const String outPath = u"../out/SimpleSlideTransitions.pptx";
// Instantiate Presentation class
SharedPtr<Presentation>pres = MakeObject<Presentation>(templatePath);
// Apply circle type transition on slide 1
pres->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);
// Apply comb type transition on slide 2
pres->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);
// Write the presentation to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/AddSlides.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Getting Slide ID
uint id = pres->get_Slides()->idx_get(0)->get_SlideId();
// Accessing Slide by ID
SharedPtr<IBaseSlide> slide = pres->GetSlideById(id);
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 templatePath = L"../templates/AddSlides.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Accessing Slide by ID
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
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 templatePath = L"../templates/AddSlides.pptx";
// Instantiate Presentation class that represents the presentation file
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Instantiate SlideCollection calss
SharedPtr<ISlideCollection> slds = pres->get_Slides();
// Accessing a slide using its slide index
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
System::Console::WriteLine(L"Slide Number from: " + slide->get_SlideNumber());
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 templatePath = L"../templates/AddSlides.pptx";
const String outPath = L"../out/AddLayoutSlides.pptx";
// Instantiate Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Try to search by layout slide type
SharedPtr<IMasterLayoutSlideCollection> layoutSlides = pres->get_Masters()->idx_get(0)->get_LayoutSlides();
SharedPtr<ILayoutSlide> layoutSlide;
if (layoutSlides->GetByType(SlideLayoutType::TitleAndObject) != NULL)
{
layoutSlide = layoutSlides->GetByType(SlideLayoutType::TitleAndObject);
}
else if(layoutSlides->GetByType(SlideLayoutType::Title) != NULL)
{
layoutSlide = layoutSlides->GetByType(SlideLayoutType::Title);
}
if (layoutSlide == NULL)
{
// The situation when a presentation doesn't contain some type of layouts.
// presentation File only contains Blank and Custom layout types.
// But layout slides with Custom types has different slide names,
// like "Title", "Title and Content", etc. And it is possible to use these
// names for layout slide selection.
// Also it is possible to use the set of placeholder shape types. For example,
// Title slide should have only Title pleceholder type, etc.
for (int i=0;i<layoutSlides->get_Count();i++)
{
SharedPtr<ILayoutSlide> titleAndObjectLayoutSlide = layoutSlides->idx_get(i);
if (titleAndObjectLayoutSlide->get_Name().Equals(L"Title and Object"))
{
layoutSlide = titleAndObjectLayoutSlide;
break;
}
}
if (layoutSlide == NULL)
{
for (int i = 0; i < layoutSlides->get_Count(); i++)
{
SharedPtr<ILayoutSlide> titleLayoutSlide = layoutSlides->idx_get(i);
if (titleLayoutSlide->get_Name().Equals(L"Title"))
{
layoutSlide = titleLayoutSlide;
break;
}
}
if (layoutSlide == NULL)
{
layoutSlide = layoutSlides->GetByType(SlideLayoutType::Blank);
if (layoutSlide == NULL)
{
layoutSlide = layoutSlides->Add(SlideLayoutType::TitleAndObject, L"Title and Object");
}
}
}
}
// Adding empty slide with added layout slide
pres->get_Slides()->InsertEmptySlide(0, layoutSlide);
// Save the PPTX file to the Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::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"../templates/AddSlides.pptx";
// Instantiate Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Instantiate SlideCollection calss
SharedPtr<ISlideCollection> slds = pres->get_Slides();
for (int i = 0; i < pres->get_LayoutSlides()->get_Count(); i++)
{
// Add an empty slide to the Slides collection
slds->AddEmptySlide(pres->get_LayoutSlides()->idx_get(i));
}
// Save the PPTX file to the Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/AddSlides.pptx";
const String outPath = L"../out/ChangeSlidePosition.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Accessing Slide by ID from collection
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Set the new position for the slide
slide->set_SlideNumber(2);
// Writing the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/AddSlides.pptx";
const String outPath = L"../out/CloneAtEndOfAnotherPresentation.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Instantiate target presentation object
SharedPtr<Presentation> destPres = MakeObject<Presentation>();
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slideCollection = destPres->get_Slides();
// Clone the desired slide at end of other presentation
slideCollection->AddClone(pres->get_Slides()->idx_get(0));
// Writing the presentation file
destPres->Save(outPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/AddSlides.pptx";
const String outPath = L"../out/CloneAtEndOfAnotherSpecificPosition.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Instantiate target presentation object
SharedPtr<Presentation> destPres = MakeObject<Presentation>();
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slideCollection = destPres->get_Slides();
// Clone the desired slide at end of other presentation
slideCollection->InsertClone(1, pres->get_Slides()->idx_get(0));
// Writing the presentation file
destPres->Save(outPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/AddSlides.pptx";
const String outPath = L"../out/CloneAnotherPresentationAtSpecifiedPosition.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Instantiate target presentation object
SharedPtr<Presentation> destPres = MakeObject<Presentation>();
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slideCollection = destPres->get_Slides();
// Clone the desired slide at end of other presentation
slideCollection->InsertClone(1,pres->get_Slides()->idx_get(0));
// Writing the presentation file
destPres->Save(outPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/AddSlides.pptx";
const String outPath = L"../out/CloneToAnotherPresentationWithMaster.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Instantiate target presentation object
SharedPtr<Presentation> destPres = MakeObject<Presentation>();
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slideCollection = destPres->get_Slides();
// Instantiate ISlide from the collection of slides in source presentation along with
// Master slide
SharedPtr<ISlide> SourceSlide = pres->get_Slides()->idx_get(0);
SharedPtr<IMasterSlide> SourceMaster = SourceSlide->get_LayoutSlide()->get_MasterSlide();
// Clone the desired master slide from the source presentation to the collection of masters in the
// Destination presentation
SharedPtr<IMasterSlideCollection> masters = destPres->get_Masters();
SharedPtr<IMasterSlide> DestMaster = SourceSlide->get_LayoutSlide()->get_MasterSlide();
// Clone the desired master slide from the source presentation to the collection of masters in the
// Destination presentation
SharedPtr<IMasterSlide> iSlide = masters->AddClone(SourceMaster);
// Clone the desired slide from the source presentation with the desired master to the end of the
// Collection of slides in the destination presentation
slideCollection->AddClone(SourceSlide, iSlide, true);
// Clone the desired slide at end of other presentation
slideCollection->InsertClone(1, pres->get_Slides()->idx_get(0));
// Writing the presentation file
destPres->Save(outPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/AddSlides.pptx";
const String outPath = L"../out/CloneToAnotherPresentationWithSetSizeAndType.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Instantiate target presentation object
SharedPtr<Presentation> destPres = MakeObject<Presentation>();
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slideCollection = destPres->get_Slides();
// Set the slide size of generated presentations to that of source
destPres->get_SlideSize()->set_Type( pres->get_SlideSize()->get_Type());
destPres->get_SlideSize()->set_Size(pres->get_SlideSize()->get_Size());
// destPres->get_SlideSize()->set_Size(Size(pres->get_SlideSize()->get_Type(),);
// Clone the desired slide at desired position of other presentation
slideCollection->InsertClone(1, pres->get_Slides()->idx_get(0));
// Writing the presentation file
destPres->Save(outPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/AddSlides.pptx";
const String outPath = L"../out/CloneWithInSamePresentation.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slides = pres->get_Slides();
// Clone the desired slide to the specified index in the same presentation
slides->InsertClone(2, pres->get_Slides()->idx_get(0));
// Writing the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/AddSlides.pptx";
const String outPath = L"../out/CloneWithinSamePresentationToEnd.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Accessing Slide by ID from collection
SharedPtr<ISlideCollection> slides = pres->get_Slides();
// Clone the desired slide at end of same presentation
slides->AddClone(pres->get_Slides()->idx_get(0));
// Writing the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../templates/AddSlides.pptx";
// Instantiate Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Instantiate SlideCollection calss
SharedPtr<ISlideCollection> slds = pres->get_Slides();
for (int i = 0; i < pres->get_LayoutSlides()->get_Count(); i++)
{
// Add an empty slide to the Slides collection
slds->AddEmptySlide(pres->get_LayoutSlides()->idx_get(i));
}
// Save the PPTX file to the Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/AddSlides.pptx";
const String outPath = L"../out/RemoveSlidesByID.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Removing a slide using its slide index
pres->get_Slides()->RemoveAt(0);
// Writing the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/AddSlides.pptx";
const String outPath = L"../out/RemoveSlidesByReference.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Accessing Slide by ID from collection
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Removing a slide using its reference
pres->get_Slides()->Remove(slide);
// Writing the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/SetPDFPageSize_out.pptx";
// Instantiate Presentation class
SharedPtr<Presentation>pres = MakeObject<Presentation>();
// Set SlideSize.Type Property
pres->get_SlideSize()->SetSize(SlideSizeType::A4Paper, SlideSizeScaleType::EnsureFit);
// Set different properties of PDF Options
Aspose::Slides::Export::PdfOptions opts = Aspose::Slides::Export::PdfOptions();
opts.set_SufficientResolution (600);
// Save presentation to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pdf, &opts);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/ManageSlidesSections_out.pptx";
// Instantiate Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
SharedPtr<ISection> section = pres->get_Sections()->idx_get(2);
pres->get_Sections()->ReorderSectionWithSlides(section, 0);
pres->get_Sections()->RemoveSectionWithSlides(pres->get_Sections()->idx_get(0));
pres->get_Sections()->AppendEmptySection(u"Last empty section");
pres->get_Sections()->idx_get(0)->set_Name(u"New section name");
pres->get_Sections()->AddSection(u"First empty", pres->get_Slides()->idx_get(2));
// Save the PPTX file to the Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/SimpleSlideTransitions.pptx";
const String outPath = u"../out/BetterSlideTransitions.pptx";
// Instantiate Presentation class
SharedPtr<Presentation>pres = MakeObject<Presentation>(templatePath);
// Apply circle type transition on slide 1
pres->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);
// Set the transition time of 3 seconds
pres->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_AdvanceOnClick(true);
pres->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_AdvanceAfterTime(3000);
// Apply comb type transition on slide 2
pres->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);
// Set the transition time of 5 seconds
pres->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceOnClick(true);
pres->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceAfterTime(5000);
// Write the presentation to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/MasterNotesSlideHeaderFooterManager_out.pptx";
SharedPtr<Presentation> presentation = MakeObject<Presentation>();
// Change Header and Footer settings for notes master and all notes slides
System::SharedPtr<IMasterNotesSlide> masterNotesSlide = presentation->get_MasterNotesSlideManager()->get_MasterNotesSlide();
if (masterNotesSlide != nullptr)
{
System::SharedPtr<IMasterNotesSlideHeaderFooterManager> headerFooterManager = masterNotesSlide->get_HeaderFooterManager();
headerFooterManager->SetHeaderAndChildHeadersVisibility(true); // make the master notes slide and all child Footer placeholders visible
headerFooterManager->SetFooterAndChildFootersVisibility(true); // make the master notes slide and all child Header placeholders visible
headerFooterManager->SetSlideNumberAndChildSlideNumbersVisibility(true); // make the master notes slide and all child SlideNumber placeholders visible
headerFooterManager->SetDateTimeAndChildDateTimesVisibility(true); // make the master notes slide and all child Date and time placeholders visible
headerFooterManager->SetHeaderAndChildHeadersText(u"Header text"); // set text to master notes slide and all child Header placeholders
headerFooterManager->SetFooterAndChildFootersText(u"Footer text"); // set text to master notes slide and all child Footer placeholders
headerFooterManager->SetDateTimeAndChildDateTimesText(u"Date and time text"); // set text to master notes slide and all child Date and time placeholders
}
// Change Header and Footer settings for first notes slide only
System::SharedPtr<INotesSlide> notesSlide = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager()->get_NotesSlide();
if (notesSlide != nullptr)
{
System::SharedPtr<INotesSlideHeaderFooterManager> headerFooterManager = notesSlide->get_HeaderFooterManager();
if (!headerFooterManager->get_IsHeaderVisible())
headerFooterManager->SetHeaderVisibility(true); // make this notes slide Header placeholder visible
if (!headerFooterManager->get_IsFooterVisible())
headerFooterManager->SetFooterVisibility(true); // make this notes slide Footer placeholder visible
if (!headerFooterManager->get_IsSlideNumberVisible())
headerFooterManager->SetSlideNumberVisibility(true); // make this notes slide SlideNumber placeholder visible
if (!headerFooterManager->get_IsDateTimeVisible())
headerFooterManager->SetDateTimeVisibility(true); // make this notes slide Date-time placeholder visible
headerFooterManager->SetHeaderText(u"New header text"); // set text to notes slide Header placeholder
headerFooterManager->SetFooterText(u"New footer text"); // set text to notes slide Footer placeholder
headerFooterManager->SetDateTimeText(u"New date and time text"); // set text to notes slide Date-time placeholder
}
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/MergeCell_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> islide = pres->get_Slides()->idx_get(0);
// Define columns with widths and rows with heights
System::ArrayPtr<double> dblCols = System::MakeObject<System::Array<double>>(4, 70);
System::ArrayPtr<double> dblRows = System::MakeObject<System::Array<double>>(4, 70);
// Add table shape to slide
SharedPtr<ITable> table = islide->get_Shapes()->AddTable(100, 50, dblCols, dblRows);
// Set border format for each cell
for (int x = 0; x < table->get_Rows()->get_Count(); x++)
{
SharedPtr<IRow> row = table->get_Rows()->idx_get(x);
for (int y = 0; y < row->get_Count(); y++)
{
SharedPtr<ICell> cell = row->idx_get(y);
cell->get_BorderTop()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderTop()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderTop()->set_Width(5);
cell->get_BorderBottom()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderBottom()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderBottom()->set_Width(5);
cell->get_BorderLeft()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderLeft()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderLeft()->set_Width(5);
cell->get_BorderRight()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderRight()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderRight()->set_Width(5);
}
}
// Merging cells (1, 1) x (2, 1)
table->MergeCells(table->idx_get(1, 1), table->idx_get(2, 1), false);
// Merging cells (1, 2) x (2, 2)
table->MergeCells(table->idx_get(1, 2), table->idx_get(2, 2), false);
// Merging cells (1, 1) x (2, 2)
table->MergeCells(table->idx_get(1, 1), table->idx_get(1, 2), false);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/MergeCells_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> islide = pres->get_Slides()->idx_get(0);
// Define columns with widths and rows with heights
System::ArrayPtr<double> dblCols = System::MakeObject<System::Array<double>>(4, 70);
System::ArrayPtr<double> dblRows = System::MakeObject<System::Array<double>>(4, 70);
// Add table shape to slide
SharedPtr<ITable> table = islide->get_Shapes()->AddTable(100, 50, dblCols, dblRows);
// Set border format for each cell
for (int x = 0; x < table->get_Rows()->get_Count(); x++)
{
SharedPtr<IRow> row = table->get_Rows()->idx_get(x);
for (int y = 0; y < row->get_Count(); y++)
{
SharedPtr<ICell> cell = row->idx_get(y);
cell->get_BorderTop()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderTop()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderTop()->set_Width(5);
cell->get_BorderBottom()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderBottom()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderBottom()->set_Width(5);
cell->get_BorderLeft()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderLeft()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderLeft()->set_Width(5);
cell->get_BorderRight()->get_FillFormat()->set_FillType(FillType::Solid);
cell->get_BorderRight()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
cell->get_BorderRight()->set_Width(5);
}
}
// Merging cells (1, 1) x (2, 1)
table->MergeCells(table->idx_get(1, 1), table->idx_get(2, 1), false);
// Merging cells (1, 2) x (2, 2)
table->MergeCells(table->idx_get(1, 2), table->idx_get(2, 2), false);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::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/ConvertToPDF_out.pdf";
const String templatePath = u"../templates/AccessSlides.pptx";
// Create an instance of Slides Metered class
SharedPtr<Metered> metered = MakeObject<Metered>();
// Access the setMeteredKey property and pass public and private keys as parameters
metered->SetMeteredKey(u"*****", u"*****");
// Get metered data amount before calling API
auto amountbefore = Aspose::Slides::Metered::GetConsumptionQuantity();
// Display information
System::Console::WriteLine(u"Amount Consumed Before: {0}", amountbefore.ToString());
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pdf);
// Get metered data amount After calling API
auto amountafter = Aspose::Slides::Metered::GetConsumptionQuantity();
// Display information
System::Console::WriteLine(u"Amount Consumed After: {0}", amountafter.ToString());
// The path to the documents directory.
const String outPath = u"../out/MultiCategoryChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();
//Clear workbook
fact->Clear(defaultWorksheetIndex);
chart->get_ChartData()->get_Series()->Clear();
chart->get_ChartData()->get_Categories()->Clear();
// Add Catrgories
SharedPtr<IChartCategory> category = chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, u"c2", ObjectExt::Box<System::String>(u"A")));
category->get_GroupingLevels()->SetGroupingItem(1, ObjectExt::Box<System::String>(u"Group1"));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, u"c3", ObjectExt::Box<System::String>(u"B")));
category = chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, u"c4", ObjectExt::Box<System::String>(u"C")));
category->get_GroupingLevels()->SetGroupingItem(1, ObjectExt::Box<System::String>(u"Group2"));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, u"c5", ObjectExt::Box<System::String>(u"D")));
category = chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, u"c6", ObjectExt::Box<System::String>(u"E")));
category->get_GroupingLevels()->SetGroupingItem(1, ObjectExt::Box<System::String>(u"Group3"));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, u"c7", ObjectExt::Box<System::String>(u"F")));
category = chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, u"c8", ObjectExt::Box<System::String>(u"G")));
category->get_GroupingLevels()->SetGroupingItem(1, ObjectExt::Box<System::String>(u"Group4"));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, u"c9", ObjectExt::Box<System::String>(u"H")));
// Now, Adding a new series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->Add(fact->GetCell(0, u"D1", ObjectExt::Box<System::String>(u"Series 1")),
ChartType::ClusteredColumn);
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, u"D2", ObjectExt::Box<double>(10)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, u"D3", ObjectExt::Box<double>(20)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, u"D4", ObjectExt::Box<double>(30)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, u"D5", ObjectExt::Box<double>(40)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, u"D6", ObjectExt::Box<double>(50)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, u"D7", ObjectExt::Box<double>(60)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, u"D8", ObjectExt::Box<double>(70)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, u"D9", ObjectExt::Box<double>(80)));
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/MultipleParagraphs_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
// Add TextFrame to the Rectangle
SharedPtr<ITextFrame> tf=ashp->AddTextFrame(u" ");
// Accessing the first Paragraph
SharedPtr<IParagraph> para0 = tf->get_Paragraphs()->idx_get(0);
SharedPtr<Portion> port01 = MakeObject<Portion>();
SharedPtr<Portion> port02 = MakeObject<Portion>();
para0->get_Portions()->Add(port01);
para0->get_Portions()->Add(port02);
// Adding second Paragraph
SharedPtr<Paragraph> para1 = MakeObject<Paragraph>();
tf->get_Paragraphs()->Add(para1);
SharedPtr<Portion> port10 = MakeObject<Portion>();
SharedPtr<Portion> port11 = MakeObject<Portion>();
SharedPtr<Portion> port12 = MakeObject<Portion>();
para1->get_Portions()->Add(port10);
para1->get_Portions()->Add(port11);
para1->get_Portions()->Add(port12);
// Adding third Paragraph
SharedPtr<Paragraph> para2 = MakeObject<Paragraph>();
tf->get_Paragraphs()->Add(para2);
SharedPtr<Portion> port20 = MakeObject<Portion>();
SharedPtr<Portion> port21 = MakeObject<Portion>();
SharedPtr<Portion> port22 = MakeObject<Portion>();
para2->get_Portions()->Add(port20);
para2->get_Portions()->Add(port21);
para2->get_Portions()->Add(port22);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
tf->get_Paragraphs()->idx_get(i)->get_Portions()->idx_get(j)->set_Text(u"Portion_"+j);
SharedPtr<IPortionFormat>format = tf->get_Paragraphs()->idx_get(i)->get_Portions()->idx_get(j)->get_PortionFormat();
if (j == 0)
{
format->get_FillFormat()->set_FillType(FillType::Solid);
format->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Red());
format->set_FontBold(NullableBool::True);
format->set_FontHeight(15);
}
else if (j == 1)
{
format->get_FillFormat()->set_FillType(FillType::Solid);
format->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Blue());
format->set_FontBold(NullableBool::True);
format->set_FontHeight(18);
}
}
}
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/MutilevelBullets_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 200, 300);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u"");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
//Clearing exisiting default paragraph
txtFrame->get_Paragraphs()->Clear();
// Create the first level bullet paragraph
SharedPtr<Paragraph> Para1 = MakeObject<Paragraph>();
SharedPtr<IParagraph> para1 = DynamicCast<IParagraph>(Para1);
para1->set_Text(u"Content");
// Setting paragraph bullet style
para1->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Symbol);
para1->get_ParagraphFormat()->get_Bullet()->set_Char(Convert::ToChar(8226));
para1->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
para1->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
para1->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
//Setting bullet level
para1->get_ParagraphFormat()->set_Depth(0);
// Create the second level bullet paragraph
SharedPtr<Paragraph> Para2 = MakeObject<Paragraph>();
SharedPtr<IParagraph> para2 = DynamicCast<IParagraph>(Para2);
para2->set_Text(u"Second level");
// Setting paragraph bullet style
para2->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Symbol);
para2->get_ParagraphFormat()->get_Bullet()->set_Char('-');
para2->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
para2->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
para2->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
//Setting bullet level
para2->get_ParagraphFormat()->set_Depth(1);
// Create the third level bullet paragraph
SharedPtr<Paragraph> Para3 = MakeObject<Paragraph>();
SharedPtr<IParagraph> para3 = DynamicCast<IParagraph>(Para3);
para3->set_Text(u"Content");
// Setting paragraph bullet style
para3->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Symbol);
para3->get_ParagraphFormat()->get_Bullet()->set_Char(Convert::ToChar(8226));
para3->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
para3->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
para3->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
//Setting bullet level
para3->get_ParagraphFormat()->set_Depth(0);
// Create the fourth level bullet paragraph
SharedPtr<Paragraph> Para4 = MakeObject<Paragraph>();
SharedPtr<IParagraph> para4 = DynamicCast<IParagraph>(Para4);
para4->set_Text(u"Fourth level");
// Setting paragraph bullet style
para4->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Symbol);
para4->get_ParagraphFormat()->get_Bullet()->set_Char('-');
para4->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
para4->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
para4->get_ParagraphFormat()->get_DefaultPortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
//Setting bullet level
para4->get_ParagraphFormat()->set_Depth(3);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/NormalCharts_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();
// Setting chart Title
chart->get_ChartTitle()->AddTextFrameForOverriding(u"Sample Title");
chart->get_ChartTitle()->get_TextFrameForOverriding()->get_TextFrameFormat()->set_CenterText ( NullableBool::True);
chart->get_ChartTitle()->set_Height(20);
chart->set_HasTitle( true);
// Delete default generated series and categories
chart->get_ChartData()->get_Series()->Clear();
chart->get_ChartData()->get_Categories()->Clear();
int s = chart->get_ChartData()->get_Series()->get_Count();
s = chart->get_ChartData()->get_Categories()->get_Count();
// Now, Adding a new series
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 1, ObjectExt::Box<System::String>(u"Series 1")), chart->get_Type());
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 2, ObjectExt::Box<System::String>(u"Series 2")), chart->get_Type());
// Add Catrgories
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 1, 0, ObjectExt::Box<System::String>(u"Caetegoty 1")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 2, 0, ObjectExt::Box<System::String>(u"Caetegoty 2")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 3, 0, ObjectExt::Box<System::String>(u"Caetegoty 3")));
// Take first chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
// Now populating series data
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 1, ObjectExt::Box<double>(20)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 1, ObjectExt::Box<double>(50)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 1, ObjectExt::Box<double>(30)));
// Setting fill color for series
series->get_Format()->get_Fill()->set_FillType(FillType::Solid);
series->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
// Take second chart series
series = chart->get_ChartData()->get_Series()->idx_get(1);
// Now populating series data
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 2, ObjectExt::Box<double>(30)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 2, ObjectExt::Box<double>(10)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 2, ObjectExt::Box<double>(60)));
// Setting fill color for series
series->get_Format()->get_Fill()->set_FillType(FillType::Solid);
series->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Green());
// First label will be show Category name
SharedPtr<IDataLabel> lbl = series->get_DataPoints()->idx_get(0)->get_Label();
lbl->get_DataLabelFormat()->set_ShowCategoryName(true);
lbl = series->get_DataPoints()->idx_get(1)->get_Label();
lbl->get_DataLabelFormat()->set_ShowSeriesName (true);
// Show value for third label
lbl = series->get_DataPoints()->idx_get(2)->get_Label();
lbl->get_DataLabelFormat()->set_ShowValue (true);
lbl->get_DataLabelFormat()->set_ShowSeriesName(true);
lbl->get_DataLabelFormat()->set_Separator (u"/");
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/NumberFormat_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
// Accessing the chart series collection
SharedPtr<IChartSeriesCollection> seriesCollection = chart->get_ChartData()->get_Series();
// Setting the preset number format
// Traverse through every chart series
for(int i = 0; i < seriesCollection->get_Count();i++)
{
auto series = seriesCollection->idx_get(i);
// Traverse through every data cell in series
for(int j=0;j<series->get_DataPoints()->get_Count();j++)
{
auto cell = series->get_DataPoints()->idx_get(j);
// Setting the number format
cell->get_Value()->get_AsCell()->set_PresetNumberFormat (10); //0.00%
}
}
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/PasswordPres.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr < Aspose::Slides::LoadOptions > loadOptions = MakeObject <Aspose::Slides::LoadOptions>();
loadOptions->set_Password(u"pass");
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath, loadOptions);
printf("Total slides inside presentation are : %d\n", pres->get_Slides()->get_Count());
// The path to the documents directory
const String templatePath = u"../templates/AccessSlides.pptx";
// Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Print slide count
printf("Total slides inside presentation are : %d\n", pres->get_Slides()->get_Count());
// The path to the documents directory.
const String templatePath = u"../templates/Video.pptx";
const String outPath = u"../out/veryLargePresentation-copy.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr < Aspose::Slides::LoadOptions > loadOptions = MakeObject <Aspose::Slides::LoadOptions>();
SharedPtr<BlobManagementOptions>blobOptions = MakeObject<BlobManagementOptions>();
blobOptions->set_PresentationLockingBehavior(PresentationLockingBehavior::KeepLocked);
loadOptions->set_BlobManagementOptions(blobOptions);
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath, loadOptions);
pres->get_Slides()->idx_get(0)->set_Name(u"Very large presentation");
// presentation will be saved to the other file, the memory consumptions still low during saving.
pres->Save(outPath, SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/SmartArt.pptx";
const String outPath = u"../out/OrganizeChartLayoutType_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Add SmartArt BasicProcess
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArt> smart = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(10, 10, 400, 300, SmartArtLayoutType::OrganizationChart);
// Accessing SmartArt node at index 0
System::SharedPtr<Aspose::Slides::SmartArt::ISmartArtNode> node0 = smart->get_AllNodes()->idx_get(0);
// Get or Set the organization chart type
node0->set_OrganizationChartLayout(OrganizationChartLayoutType::LeftHanging);
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ParagraphBullets_out.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
const String ImagePath = u"../templates/Tulips.jpg";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u"");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
txtFrame->get_Paragraphs()->Clear();
// Create the Paragraph object for text frame
SharedPtr<Paragraph> paragraph = MakeObject<Paragraph>();
//Setting Text
paragraph->set_Text(u"Welcome to Aspose.Slides");
// Setting bullet indent
paragraph->get_ParagraphFormat()->set_Indent (25);
// Setting bullet color
paragraph->get_ParagraphFormat()->get_Bullet()->get_Color()->set_ColorType ( ColorType::RGB);
paragraph->get_ParagraphFormat()->get_Bullet()->get_Color()->set_Color(Color::get_Black());
// set IsBulletHardColor to true to use own bullet color
paragraph->get_ParagraphFormat()->get_Bullet()->set_IsBulletHardColor(NullableBool::True);
// Setting Bullet Height
paragraph->get_ParagraphFormat()->get_Bullet()->set_Height(100);
// Adding Paragraph to text frame
txtFrame->get_Paragraphs()->Add(paragraph);
// Creating second paragraph
// Create the Paragraph object for text frame
SharedPtr<Paragraph> paragraph2 = MakeObject<Paragraph>();
//Setting Text
paragraph2->set_Text(u"This is numbered bullet");
// Setting paragraph bullet type and style
paragraph2->get_ParagraphFormat()->get_Bullet()->set_Type ( BulletType::Numbered);
paragraph2->get_ParagraphFormat()->get_Bullet()->set_NumberedBulletStyle ( NumberedBulletStyle::BulletCircleNumWDBlackPlain);
// Setting bullet indent
paragraph2->get_ParagraphFormat()->set_Indent(25);
// Setting bullet color
paragraph2->get_ParagraphFormat()->get_Bullet()->get_Color()->set_ColorType(ColorType::RGB);
paragraph2->get_ParagraphFormat()->get_Bullet()->get_Color()->set_Color(Color::get_Black());
// set IsBulletHardColor to true to use own bullet color
paragraph2->get_ParagraphFormat()->get_Bullet()->set_IsBulletHardColor(NullableBool::True);
// Setting Bullet Height
paragraph2->get_ParagraphFormat()->get_Bullet()->set_Height(100);
// Adding Paragraph to text frame
txtFrame->get_Paragraphs()->Add(paragraph2);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ParagraphsAlignment_out.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing the first and second placeholder in the slide and typecasting it as AutoShape
SharedPtr<IShape> shape1 = slide->get_Shapes()->idx_get(0);
SharedPtr<IShape> shape2 = slide->get_Shapes()->idx_get(1);
SharedPtr<AutoShape> ashp1 = DynamicCast<Aspose::Slides::AutoShape>(shape1);
SharedPtr<AutoShape> ashp2 = DynamicCast<Aspose::Slides::AutoShape>(shape2);
SharedPtr<ITextFrame> tf1 = ashp1->get_TextFrame();
SharedPtr<ITextFrame> tf2 = ashp2->get_TextFrame();
// Change the text in both placeholders
tf1->set_Text (u"Center Align by Aspose");
tf2->set_Text(u"Center Align by Aspose");
// Accessing the first Paragraph
SharedPtr<IParagraph> para1 = tf1->get_Paragraphs()->idx_get(0);
SharedPtr<IParagraph> para2 = tf2->get_Paragraphs()->idx_get(0);
// Aligning the text paragraph to center
para1->get_ParagraphFormat()->set_Alignment (TextAlignment::Center);
para2->get_ParagraphFormat()->set_Alignment(TextAlignment::Center);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/PictureFrameFormatting_out.pptx";
const String filePath = u"../templates/Tulips.jpg";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Load Image to be added in presentaiton image collection
// Get the picture
auto bitmap = MakeObject<System::Drawing::Bitmap>(filePath);
// Add image to presentation's images collection
SharedPtr<IPPImage> imgx = pres->get_Images()->AddImage(bitmap);
// Add picture frame to slide
SharedPtr<IPictureFrame> pf = slide->get_Shapes()->AddPictureFrame(ShapeType::Rectangle, 50, 50, 100, 100, imgx);
// Setting relative scale width and height
pf->set_RelativeScaleHeight(0.8);
pf->set_RelativeScaleWidth(1.35);
// Apply some formatting to PictureFrame
pf->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid);
pf->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Blue());
pf->get_LineFormat()->set_Width ( 20);
pf->set_Rotation( 45);
//Write the PPTX file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/PictureOrganizationChart_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Adding Picture Organization Chart
System::SharedPtr<ISmartArt> smartArt = pres->get_Slides()->idx_get(0)->get_Shapes()->AddSmartArt(0, 0, 400, 400, Aspose::Slides::SmartArt::SmartArtLayoutType::PictureOrganizationChart);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/PieChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Pie, 0, 0, 500, 500);
// Setting chart Title
chart->get_ChartTitle()->AddTextFrameForOverriding(u"Sample Title");
chart->get_ChartTitle()->get_TextFrameForOverriding()->get_TextFrameFormat()->set_CenterText(NullableBool::True);
chart->get_ChartTitle()->set_Height(20);
chart->set_HasTitle(true);
// Delete default generated series and categories
chart->get_ChartData()->get_Series()->Clear();
chart->get_ChartData()->get_Categories()->Clear();
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();
// Add Catrgories
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 1, 0, ObjectExt::Box<System::String>(u"First Qtr")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 2, 0, ObjectExt::Box<System::String>(u"2nd Qtr")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 3, 0, ObjectExt::Box<System::String>(u"3ed Qtr")));
// Now, Adding a new series
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 1, ObjectExt::Box<System::String>(u"Series 1")), chart->get_Type());
// Take first chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
// Now populating series data
series->get_DataPoints()->AddDataPointForPieSeries(fact->GetCell(defaultWorksheetIndex, 1, 1, ObjectExt::Box<double>(20)));
series->get_DataPoints()->AddDataPointForPieSeries(fact->GetCell(defaultWorksheetIndex, 2, 1, ObjectExt::Box<double>(50)));
series->get_DataPoints()->AddDataPointForPieSeries(fact->GetCell(defaultWorksheetIndex, 3, 1, ObjectExt::Box<double>(30)));
chart->get_ChartData()->get_SeriesGroups()->idx_get(0)->set_IsColorVaried(true);
SharedPtr<IChartDataPoint> point = series->get_DataPoints()->idx_get(0);
point->get_Format()->get_Fill()->set_FillType(FillType::Solid);
point->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Cyan());
// Setting Sector border
point->get_Format()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid);
point->get_Format()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Gray());
point->get_Format()->get_Line()->set_Width ( 3.0);
point->get_Format()->get_Line()->set_Style( LineStyle::ThinThick);
point->get_Format()->get_Line()->set_DashStyle ( LineDashStyle::DashDot);
SharedPtr<IChartDataPoint> point1 = series->get_DataPoints()->idx_get(1);
point1->get_Format()->get_Fill()->set_FillType(FillType::Solid);
point1->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Brown());
// Setting Sector border
point1->get_Format()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid);
point1->get_Format()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Blue());
point1->get_Format()->get_Line()->set_Width (3.0);
point1->get_Format()->get_Line()->set_Style(LineStyle::Single);
point1->get_Format()->get_Line()->set_DashStyle(LineDashStyle::LargeDashDot);
SharedPtr<IChartDataPoint> point2 = series->get_DataPoints()->idx_get(2);
point2->get_Format()->get_Fill()->set_FillType(FillType::Solid);
point2->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Coral());
// Setting Sector border
point2->get_Format()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid);
point2->get_Format()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
point2->get_Format()->get_Line()->set_Width (2.0);
point2->get_Format()->get_Line()->set_Style(LineStyle::ThickThin);
point2->get_Format()->get_Line()->set_DashStyle(LineDashStyle::LargeDashDotDot);
// Create custom labels for each of categories for new series
SharedPtr<IDataLabel> lbl1 = series->get_DataPoints()->idx_get(0)->get_Label();
// lbl.ShowCategoryName = true;
lbl1->get_DataLabelFormat()->set_ShowValue(true);
SharedPtr<IDataLabel> lbl2 = series->get_DataPoints()->idx_get(1)->get_Label();
lbl2->get_DataLabelFormat()->set_ShowValue(true);
lbl2->get_DataLabelFormat()->set_ShowLegendKey(true);
lbl2->get_DataLabelFormat()->set_ShowPercentage(true);
SharedPtr<IDataLabel> lbl3 = series->get_DataPoints()->idx_get(2)->get_Label();
lbl3->get_DataLabelFormat()->set_ShowSeriesName(true);
lbl3->get_DataLabelFormat()->set_ShowPercentage(true);
// Showing Leader Lines for Chart
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowLeaderLines ( true);
// Setting Rotation Angle for Pie Chart Sectors
chart->get_ChartData()->get_SeriesGroups()->idx_get(0)->set_FirstSliceAngle ( 180);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/PPTtoPPTX_out.pptx";
const String dataDir = u"../templates/SampleChart.ppt";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(dataDir);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/PresentationToTIFFWithCustomImagePixelFormat_out.tiff";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
SharedPtr<Aspose::Slides::Export::TiffOptions> tiffOptions = MakeObject <Aspose::Slides::Export::TiffOptions>();
tiffOptions->set_PixelFormat(ImagePixelFormat::Format8bppIndexed);
//Saving to Tiff
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Tiff, tiffOptions);
// The path to the documents directory.
const String outPath = u"../out/PresentationToTIFFWithDefaultSize_out.tiff";
const String templatePath = u"../templates/AccessSlides.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Saving to Tiff
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Tiff);
// The path to the documents directory.
const String templatePath = u"../templates/SmartArt.pptx";
const String outPath = u"../out/RemoveNode_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Traverse through every shape inside first slide
for (int x = 0; x < pres->get_Slides()->idx_get(0)->get_Shapes()->get_Count(); x++)
{
SharedPtr<IShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(x);
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape))
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArt> smart = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArt>(shape);
if (smart->get_AllNodes()->get_Count() > 0)
{
// Accessing SmartArt node at index 0
System::SharedPtr<Aspose::Slides::SmartArt::SmartArtNode> node0 = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtNode>(smart->get_AllNodes()->idx_get(0));
// Removing the selected node
smart->get_AllNodes()->RemoveNode(node0);
}
}
}
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/SmartArt.pptx";
const String outPath = u"../out/RemoveSmartArtNodeByPosition_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Traverse through every shape inside first slide
for (int x = 0; x < pres->get_Slides()->idx_get(0)->get_Shapes()->get_Count(); x++)
{
SharedPtr<IShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->idx_get(x);
if (System::ObjectExt::Is<Aspose::Slides::SmartArt::SmartArt>(shape))
{
System::SharedPtr<Aspose::Slides::SmartArt::SmartArt> smart = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArt>(shape);
if (smart->get_AllNodes()->get_Count() > 0)
{
// Accessing SmartArt node at index 0
System::SharedPtr<Aspose::Slides::SmartArt::SmartArtNode> node0 = System::DynamicCast_noexcept<Aspose::Slides::SmartArt::SmartArtNode>(smart->get_AllNodes()->idx_get(0));
if (node0->get_ChildNodes()->get_Count() >= 2)
{
// Removing the child node at position 1
node0->get_ChildNodes()->RemoveNode(1);
}
}
}
}
// Save Presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AccessSlides.pptx";
const String outPath = u"../out/RemoveNotesAtSpecificSlide.pptx";
// Instantiate Presentation class
SharedPtr<Presentation>pres = MakeObject<Presentation>(templatePath);
// Removing notes of all slides
SharedPtr<INotesSlideManager> mgr;
//Removing notes from first slide
mgr = pres->get_Slides()->idx_get(0)->get_NotesSlideManager();
mgr->RemoveNotesSlide();
// Save presentation to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AccessSlides.pptx";
const String outPath = u"../out/RemovedAllNotes.pptx";
// Instantiate Presentation class
SharedPtr<Presentation>pres = MakeObject<Presentation>(templatePath);
// Removing notes of all slides
SharedPtr<INotesSlideManager> mgr ;
for (int i = 0; i < pres->get_Slides()->get_Count(); i++)
{
mgr = pres->get_Slides()->idx_get(i)->get_NotesSlideManager();
mgr->RemoveNotesSlide();
}
// Save presentation to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/ProtectedSample.pptx";
const String outPath = u"../out/RemoveProtectionSample.pptx";
//Instatiate Presentation class that represents a PPTX
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//ISlide object for accessing the slides in the presentation
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
//IShape object for holding temporary shapes
SharedPtr<IShape> shape;
//Traversing through all the slides in the presentation
for (int slideCount = 0; slideCount < pres->get_Slides()->get_Count(); slideCount++)
{
slide = pres->get_Slides()->idx_get(slideCount);
//Travesing through all the shapes in the slides
for (int count = 0; count < slide->get_Shapes()->get_Count(); count++)
{
shape = slide->get_Shapes()->idx_get(count);
if (System::ObjectExt::Is<IAutoShape>(shape)) {
//Type casting to Auto shape and getting auto shape lock
SharedPtr<IAutoShape> aShp = DynamicCast<Aspose::Slides::IAutoShape>(shape);
SharedPtr<IAutoShapeLock> autoShapeLock = DynamicCast<Aspose::Slides::IAutoShapeLock>(aShp->get_ShapeLock());
//Applying shapes locks
autoShapeLock->set_PositionLocked(false);
autoShapeLock->set_SelectLocked(false);
autoShapeLock->set_SizeLocked(false);
}
//if shape is group shape
else if (System::ObjectExt::Is<IGroupShape>(shape)) {
//Type casting to group shape and getting group shape lock
SharedPtr<IGroupShape> group = DynamicCast<Aspose::Slides::IGroupShape>(shape);
SharedPtr<IGroupShapeLock> groupShapeLock = DynamicCast<Aspose::Slides::IGroupShapeLock>(group->get_ShapeLock());
//Applying shapes locks
groupShapeLock->set_GroupingLocked(false);
groupShapeLock->set_PositionLocked(false);
groupShapeLock->set_SelectLocked(false);
groupShapeLock->set_SizeLocked(false);
}
//if shape is a connector
else if (System::ObjectExt::Is<IConnector>(shape)) {
//Type casting to connector shape and getting connector shape lock
SharedPtr<IConnector> conn = DynamicCast<Aspose::Slides::IConnector>(shape);
SharedPtr<IConnectorLock> connLock = DynamicCast<Aspose::Slides::IConnectorLock>(conn->get_ShapeLock());
//Applying shapes locks
connLock->set_PositionMove(false);
connLock->set_SelectLocked(false);
connLock->set_SizeLocked(false);
}
//if shape is picture frame
else if (System::ObjectExt::Is<IPictureFrame>(shape)) {
//Type casting to pitcture frame shape and getting picture frame shape lock
SharedPtr<IPictureFrame> pic = DynamicCast<Aspose::Slides::IPictureFrame>(shape);
SharedPtr<IPictureFrameLock> picLock = DynamicCast<Aspose::Slides::IPictureFrameLock>(pic->get_ShapeLock());
//Applying shapes locks
picLock->set_PositionLocked(false);
picLock->set_SelectLocked(false);
picLock->set_SizeLocked(false);
}
}
}
//Saving the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/RemoveShape_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Now create effect "PathFootball" for existing shape from scratch.
SharedPtr<IAutoShape> autoShape1 = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 40, 150, 50);
SharedPtr<IAutoShape> autoShape2 = slide->get_Shapes()->AddAutoShape(ShapeType::Moon, 160, 40, 150, 50);
String alttext = u"User Defined";
int iCount = slide->get_Shapes()->get_Count();
for (int i = 0; i < iCount; i++)
{
// Accessing the added shape
SharedPtr<Shape> ashape = DynamicCast<Aspose::Slides::Shape>(slide->get_Shapes()->idx_get(i));
if (String::Compare(ashape->get_AlternativeText(), alttext, StringComparison::Ordinal) == 0)
{
slide->get_Shapes()->Remove(ashape);
}
}
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/RemoveSlidesByID.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Removing a slide using its slide index
pres->get_Slides()->RemoveAt(0);
// Writing the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/AddSlides.pptx";
const String outPath = u"../out/RemoveSlidesByReference.pptx";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Accessing Slide by ID from collection
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Removing a slide using its reference
pres->get_Slides()->Remove(slide);
// Writing the presentation file
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/RemoveVBAMacros_out.pptm";
const String templatePath = u"../templates/vba.pptm";
// Load the desired the presentation
SharedPtr<Presentation> presentation = MakeObject<Presentation>(templatePath);
// Access the Vba module and remove
presentation->get_VbaProject()->get_Modules()->Remove(presentation->get_VbaProject()->get_Modules()->idx_get(0));
// Save PPTX to Disk
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptm);
const String outPath = u"../out/RemoveWriteProtection_out.ppt";
const String templatePath = u"../templates/RemoveWriteProtection.pptx";
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
if (pres->get_ProtectionManager()->get_IsWriteProtected()) {
pres->get_ProtectionManager()->RemoveWriteProtection();
}
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/RemovingRowColumn_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> islide = pres->get_Slides()->idx_get(0);
// Define columns with widths and rows with heights
System::ArrayPtr<double> dblCols = System::MakeObject<System::Array<double>>(4, 70);
System::ArrayPtr<double> dblRows = System::MakeObject<System::Array<double>>(4, 70);
// Add table shape to slide
SharedPtr<ITable> table = islide->get_Shapes()->AddTable(100, 50, dblCols, dblRows);
table->get_Rows()->RemoveAt(1, false);
table->get_Columns()->RemoveAt(1, false);
// Merging cells (1, 1) x (2, 1)
table->MergeCells(table->idx_get(1, 1), table->idx_get(2, 1), false);
// Merging cells (1, 2) x (2, 2)
table->MergeCells(table->idx_get(1, 2), table->idx_get(2, 2), false);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/TestDeck_050.pptx";
const String outPath = u"../out/RenderComments_out.png";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Create bitmap object
auto bmp = MakeObject<Bitmap>(740, 960);
SharedPtr<Graphics> graphics = Graphics::FromImage(bmp);
// Access the first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
SharedPtr<NotesCommentsLayoutingOptions>opts = MakeObject<NotesCommentsLayoutingOptions>();
opts->set_CommentsAreaColor ( Color::get_Red());
opts->set_CommentsAreaWidth ( 200);
opts->set_CommentsPosition(CommentsPositions::Right);
opts->set_NotesPosition(NotesPositions::BottomTruncated);
// Access and render the first slide
pres->get_Slides()->idx_get(0)->RenderToGraphics(opts, graphics);
try {
bmp->Save(outPath, ImageFormat::get_Png());
}
catch (Exception e)
{
System::Console::WriteLine(u"Exception " + e.get_Message());
}
const String outPath = u"../out/HTML_Notes_out.hmtl";
const String templatePath = u"../templates/AccessSlides.pptx";
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//pres->get_ProtectionManager()->Encrypt(u"pass");
//...do some work here..
SharedPtr<HtmlOptions> htmlOptions = MakeObject< HtmlOptions>();
System::SharedPtr<INotesCommentsLayoutingOptions> options = htmlOptions->get_NotesCommentsLayouting();
options->set_NotesPosition(NotesPositions::BottomFull);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Html, htmlOptions);
// The path to the documents directory.
const String outPNG = u"../out/Slide_0.png";
const String templatePath = u"../templates/input.pptx";
// Create new instance of a rules collection
System::SharedPtr<IFontFallBackRulesCollection> rulesList = System::MakeObject<FontFallBackRulesCollection>();
// create a number of rules
rulesList->Add(System::MakeObject<FontFallBackRule>(static_cast<uint32_t>(0x400), static_cast<uint32_t>(0x4FF), u"Times New Roman"));
auto fallBackRule_enumerator = rulesList->GetEnumerator();
while (fallBackRule_enumerator->MoveNext())
{
auto fallBackRule = fallBackRule_enumerator->get_Current();
//Trying to remove FallBack font "Tahoma" from loaded rules
fallBackRule->Remove(u"Tahoma");
//And to update of rules for specified range
if ((fallBackRule->get_RangeEndIndex() >= static_cast<uint32_t>(0x4000)) && (fallBackRule->get_RangeStartIndex() < static_cast<uint32_t>(0x5000)))
{
fallBackRule->AddFallBackFonts(u"Verdana");
}
}
//Also we can remove any existing rules from list
if (rulesList->get_Count() > 0)
{
rulesList->Remove(rulesList->idx_get(0));
}
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
//Assigning a prepared rules list for using
pres->get_FontsManager()->set_FontFallBackRulesCollection(rulesList);
// Rendering of thumbnail with using of initialized rules collection and saving to PNG
pres->get_Slides()->idx_get(0)->GetThumbnail(1.f, 1.f)->Save(outPNG, System::Drawing::Imaging::ImageFormat::get_Png());
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 templatePath = L"../templates/TestDeck_050.pptx";
const String outPath = L"../out/Aspose_out.svg";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access the first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Create a memory stream object
SharedPtr<System::IO::MemoryStream> SvgStream = MakeObject<System::IO::MemoryStream>();
// Generate SVG image of slide and save in memory stream
slide->WriteAsSvg(SvgStream);
SvgStream->set_Position ( 0);
// Save memory stream to file
try
{
auto fs = File::OpenWrite(outPath);
//ArrayPtr<byte> buffer;// = ArrayPtr<byte>();
ArrayPtr<byte> buffer= ArrayPtr<byte>();
// int len;
// len = SvgStream->Read(buffer, 0, buffer->Count());
/// while ((len = SvgStream->Read(buffer, 0, SvgStream->get_Capacity())) > 0)
{
// fs->Write(buffer, 0, len);
fs->Write(SvgStream->GetBuffer(), 0, SvgStream->get_Length());
}
}
catch (Exception e)
{
}
SvgStream->Close();
// The path to the documents directory.
const String templatePath = u"../templates/TestDeck_050.pptx";
const String outPath = u"../out/Aspose_out.svg";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access the first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Create a memory stream object
SharedPtr<System::IO::MemoryStream> SvgStream = MakeObject<System::IO::MemoryStream>();
// Generate SVG image of slide and save in memory stream
slide->WriteAsSvg(SvgStream);
SvgStream->set_Position ( 0);
// Save memory stream to file
try
{
auto fs = File::OpenWrite(outPath);
//ArrayPtr<byte> buffer;// = ArrayPtr<byte>();
//ArrayPtr<byte> buffer= ArrayPtr<byte>();
// int len;
// len = SvgStream->Read(buffer, 0, buffer->Count());
/// while ((len = SvgStream->Read(buffer, 0, SvgStream->get_Capacity())) > 0)
{
// fs->Write(buffer, 0, len);
fs->Write(SvgStream->GetBuffer(), 0, SvgStream->get_Length());
}
}
catch (Exception e)
{
}
SvgStream->Close();
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 templatePath = L"../templates/TestDeck_050.pptx";
const String outPath = L"../out/Aspose_out.png";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access the first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
auto bitmap = slide->GetThumbnail(1, 1);
bitmap->Save(outPath, ImageFormat::get_Png());
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 templatePath = L"../templates/TestDeck_050.pptx";
const String outPath = L"../out/Aspose_NotesSlide_out.png";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access the first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// User defined dimension
int desiredX = 1200;
int desiredY = 800;
// Create a full scale image
auto bitmap = slide->get_NotesSlideManager()->get_NotesSlide()->GetThumbnail(2, 2);
bitmap->Save(outPath, ImageFormat::get_Png());
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 templatePath = L"../templates/TestDeck_050.pptx";
const String outPath = L"../out/Aspose_UserDefinedDimension_Slide_out.png";
// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access the first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// User defined dimension
int desiredX = 1200;
int desiredY = 800;
// Getting scaled value of X and Y
float ScaleX = (float)(1.0 / pres->get_SlideSize()->get_Size().get_Width()) * desiredX;
float ScaleY = (float)(1.0 / pres->get_SlideSize()->get_Size().get_Height()) * desiredY;
// Create a custom scale image
auto bitmap = slide->get_NotesSlideManager()->get_NotesSlide()->GetThumbnail(ScaleX, ScaleY);
bitmap->Save(outPath, ImageFormat::get_Png());
// The path to the documents directory.
const String outPath = u"../out/ReplaceFontsExplicitly_out.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Define new fonts
SharedPtr<FontData> sourceFont = MakeObject<FontData>(u"Arial");
SharedPtr<FontData> destFont = MakeObject<FontData>(u"Times New Roman");
// Replace the fonts
pres->get_FontsManager()->ReplaceFont(sourceFont, destFont);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ReplacingText_out.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing the first and second placeholder in the slide and typecasting it as AutoShape
// Accessing the first and second placeholder in the slide and typecasting it as AutoShape
SharedPtr<IShape> shape = slide->get_Shapes()->idx_get(0);
SharedPtr<AutoShape> ashp = DynamicCast<Aspose::Slides::AutoShape>(shape);
SharedPtr<ITextFrame> textframe = ashp->get_TextFrame();
textframe->set_Text(u"This is Placeholder");
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/RotatingShapes_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
SharedPtr<IAutoShape> autoShape1 = slide->get_Shapes()->AddAutoShape(ShapeType::Ellipse, 50, 40, 150, 50);
// Rotate the shape to 90 degree
autoShape1->set_Rotation(90);
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/RotatingText.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
const String ImagePath = u"../templates/Tulips.jpg";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u"");
ashp->get_FillFormat()->set_FillType(FillType::NoFill);
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
txtFrame->get_TextFrameFormat()->set_TextVerticalType(TextVerticalType::Vertical270);
// Create the Paragraph object for text frame
SharedPtr<IParagraph> paragraph = txtFrame->get_Paragraphs()->idx_get(0);
// Create Portion object for paragraph
SharedPtr<IPortion>portion = paragraph->get_Portions()->idx_get(0);
portion->set_Text (u"A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.");
portion->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
portion->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/RuleBasedFontsReplacement_out.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
// Define new fonts
SharedPtr<IFontData> sourceFont = MakeObject<FontData>(u"SomeRareFont");
SharedPtr<IFontData> destFont = MakeObject<FontData>(u"Arial");
// Add font rule for font replacement
SharedPtr<FontSubstRule> fontSubstRule = MakeObject<FontSubstRule>(sourceFont, destFont, FontSubstCondition::WhenInaccessible);
// Add rule to font substitute rules collection
SharedPtr<FontSubstRuleCollection> fontSubstRuleCollection = MakeObject<FontSubstRuleCollection>();
fontSubstRuleCollection->Add(fontSubstRule);
// Add font rule collection to rule list
pres->get_FontsManager()->set_FontSubstRuleList ( fontSubstRuleCollection);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String outPath = u"../out/SaveAsPredefinedViewType_out.ppt";
SharedPtr<Presentation> pres = MakeObject<Presentation>();
pres->get_ViewProperties()->set_LastView(Aspose::Slides::ViewType::SlideMasterView);
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String outPath = u"../out/SaveAsReadOnly_out.ppt";
SharedPtr<Presentation> pres = MakeObject<Presentation>();
pres->get_ProtectionManager()->SetWriteProtection(u"test");
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String outPath = u"../out/SaveProperties_out.pptx";
SharedPtr<Presentation> pres = MakeObject<Presentation>();
pres->get_ProtectionManager()->set_EncryptDocumentProperties(false);
pres->get_ProtectionManager()->Encrypt(u"pass");
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String outPath = u"../out/SaveToFile_out.ppt";
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//pres->get_ProtectionManager()->Encrypt(u"pass");
//...do some work here..
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String outPath = u"../out/Save_As_Stream_out.pptx";
SharedPtr<Presentation> pres = MakeObject<Presentation>();
SharedPtr<IAutoShape> shape = pres->get_Slides()->idx_get(0)->get_Shapes()->AddAutoShape(Aspose::Slides::ShapeType::Rectangle, 200, 200, 200, 200);
/// Load the video file to stream
System::SharedPtr<System::IO::Stream> stream = System::MakeObject<System::IO::FileStream>(outPath, System::IO::FileMode::Create);
pres->Save(stream, Aspose::Slides::Export::SaveFormat::Pptx);
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
const String outPath = u"../out/SaveToStrictOpenXML_out.pptx";
//Instantiate Presentation object
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
//Setting options for strick XML
SharedPtr<PptxOptions> options = MakeObject<PptxOptions>();
options->set_Conformance(Conformance::Iso29500_2008_Strict);
//Save presentation
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx, options);
const String outPath = u"../out/SaveWithPassword_out.ppt";
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//...do some work here..
pres->get_ProtectionManager()->Encrypt(u"pass");
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/HTMLAndCSSFileWhenExportingIntoHTML_out.svg";
const String templatePath = u"../templates/AccessSlides.pptx";
{
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(templatePath);
// Clearing resources under 'using' statement
// System::Details::DisposeGuard __dispose_guard_0{ pres, ASPOSE_CURRENT_FUNCTION };
// ------------------------------------------
System::SharedPtr<CustomHeaderAndFontsController> htmlController = System::MakeObject<CustomHeaderAndFontsController>(u"styles.css");
System::SharedPtr<HtmlOptions> options = [&]{ auto tmp_0 = System::MakeObject<HtmlOptions>(); tmp_0->set_HtmlFormatter(HtmlFormatter::CreateCustomFormatter(htmlController)); return tmp_0; }();
pres->Save(u"pres.html", Aspose::Slides::Export::SaveFormat::Html, options);
// The path to the documents directory.
const String outPath = u"../out/ScatteredChart_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ScatterWithSmoothLines, 0, 0, 500, 500);
// Setting chart Title
chart->get_ChartTitle()->AddTextFrameForOverriding(u"Sample Title");
chart->get_ChartTitle()->get_TextFrameForOverriding()->get_TextFrameFormat()->set_CenterText(NullableBool::True);
chart->get_ChartTitle()->set_Height(20);
chart->set_HasTitle(true);
// Delete default generated series
chart->get_ChartData()->get_Series()->Clear();
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();
// Now, Adding a new series
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 1, 1, ObjectExt::Box<System::String>(u"Series 1")), chart->get_Type());
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 1, 3, ObjectExt::Box<System::String>(u"Series 2")), chart->get_Type());
// Take first chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
// Add new point (1:3) there.
series->get_DataPoints()->AddDataPointForScatterSeries(fact->GetCell(defaultWorksheetIndex, 2, 1, ObjectExt::Box<double>(1)), fact->GetCell(defaultWorksheetIndex, 2, 2, ObjectExt::Box<double>(3)));
// Add new point (2:10)
series->get_DataPoints()->AddDataPointForScatterSeries(fact->GetCell(defaultWorksheetIndex, 3, 1, ObjectExt::Box<double>(2)), fact->GetCell(defaultWorksheetIndex, 3, 2, ObjectExt::Box<double>(10)));
// Edit the type of series
series->set_Type (ChartType::ScatterWithStraightLinesAndMarkers);
// Changing the chart series marker
series->get_Marker()->set_Size (10);
series->get_Marker()->set_Symbol(MarkerStyleType::Star);
// Take second chart series
series = chart->get_ChartData()->get_Series()->idx_get(1);
// Add new point (5:2) there.
series->get_DataPoints()->AddDataPointForScatterSeries(fact->GetCell(defaultWorksheetIndex, 2, 3, ObjectExt::Box<double>(5)), fact->GetCell(defaultWorksheetIndex, 2, 4, ObjectExt::Box<double>(2)));
// Add new point (3:1)
series->get_DataPoints()->AddDataPointForScatterSeries(fact->GetCell(defaultWorksheetIndex, 3, 3, ObjectExt::Box<double>(3)), fact->GetCell(defaultWorksheetIndex, 3, 4, ObjectExt::Box<double>(1)));
// Add new point (2:2)
series->get_DataPoints()->AddDataPointForScatterSeries(fact->GetCell(defaultWorksheetIndex, 4, 3, ObjectExt::Box<double>(2)), fact->GetCell(defaultWorksheetIndex, 4, 4, ObjectExt::Box<double>(2)));
// Add new point (5:1)
series->get_DataPoints()->AddDataPointForScatterSeries(fact->GetCell(defaultWorksheetIndex, 5, 3, ObjectExt::Box<double>(5)), fact->GetCell(defaultWorksheetIndex, 5, 4, ObjectExt::Box<double>(1)));
// Changing the chart series marker
series->get_Marker()->set_Size ( 10);
series->get_Marker()->set_Symbol(MarkerStyleType::Circle);
chart->get_ChartData()->get_SeriesGroups()->idx_get(0)->set_IsColorVaried(true);
SharedPtr<IChartDataPoint> point = series->get_DataPoints()->idx_get(0);
point->get_Format()->get_Fill()->set_FillType(FillType::Solid);
point->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Cyan());
// Setting Sector border
point->get_Format()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid);
point->get_Format()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Gray());
point->get_Format()->get_Line()->set_Width ( 3.0);
point->get_Format()->get_Line()->set_Style(LineStyle::ThinThick);
point->get_Format()->get_Line()->set_DashStyle(LineDashStyle::DashDot);
SharedPtr<IChartDataPoint> point1 = series->get_DataPoints()->idx_get(1);
point1->get_Format()->get_Fill()->set_FillType(FillType::Solid);
point1->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Brown());
// Setting Sector border
point1->get_Format()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid);
point1->get_Format()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Blue());
point1->get_Format()->get_Line()->set_Width (3.0);
point1->get_Format()->get_Line()->set_Style(LineStyle::Single);
point1->get_Format()->get_Line()->set_DashStyle(LineDashStyle::LargeDashDot);
SharedPtr<IChartDataPoint> point2 = series->get_DataPoints()->idx_get(2);
point2->get_Format()->get_Fill()->set_FillType(FillType::Solid);
point2->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Coral());
// Setting Sector border
point2->get_Format()->get_Line()->get_FillFormat()->set_FillType(FillType::Solid);
point2->get_Format()->get_Line()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
point2->get_Format()->get_Line()->set_Width ( 2.0);
point2->get_Format()->get_Line()->set_Style(LineStyle::ThickThin);
point2->get_Format()->get_Line()->set_DashStyle(LineDashStyle::LargeDashDotDot);
// Create custom labels for each of categories for new series
SharedPtr<IDataLabel> lbl1 = series->get_DataPoints()->idx_get(0)->get_Label();
// lbl.ShowCategoryName = true;
lbl1->get_DataLabelFormat()->set_ShowValue(true);
SharedPtr<IDataLabel> lbl2 = series->get_DataPoints()->idx_get(1)->get_Label();
lbl2->get_DataLabelFormat()->set_ShowValue(true);
lbl2->get_DataLabelFormat()->set_ShowLegendKey(true);
lbl2->get_DataLabelFormat()->set_ShowPercentage(true);
SharedPtr<IDataLabel> lbl3 = series->get_DataPoints()->idx_get(2)->get_Label();
lbl3->get_DataLabelFormat()->set_ShowSeriesName(true);
lbl3->get_DataLabelFormat()->set_ShowPercentage(true);
// Showing Leader Lines for Chart
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowLeaderLines(true);
// Setting Rotation Angle for Pie Chart Sectors
chart->get_ChartData()->get_SeriesGroups()->idx_get(0)->set_FirstSliceAngle(180);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/SecondPlotOptionsforCharts_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::Pie, 0, 0, 500, 500);
// Take first chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);
// Set different properties
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true);
series->get_ParentSeriesGroup()->set_SecondPieSize ( 149);
series->get_ParentSeriesGroup()->set_PieSplitBy ( Aspose::Slides::Charts::PieSplitType::ByPercentage);
series->get_ParentSeriesGroup()->set_PieSplitPosition ( 53);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
const String pdfFilePath = u"../out/PDFWithPermissions.pdf";
auto pdfOptions = System::MakeObject<PdfOptions>();
pdfOptions->set_Password(u"my_password");
pdfOptions->set_AccessPermissions(Aspose::Slides::Export::PdfAccessPermissions::PrintDocument | Aspose::Slides::Export::PdfAccessPermissions::HighQualityPrint);
auto presentation = System::MakeObject<Presentation>();
presentation->Save(pdfFilePath, Aspose::Slides::Export::SaveFormat::Pdf, pdfOptions);
// The path to the documents directory.
const String outPath = u"../out/SetAlternativeText_out.pptx";
const String templatePath = u"../templates/ConnectorLineAngle.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Accessing shapes collection for selected slide
SharedPtr<IShapeCollection> shapes = slide->get_Shapes();
// Now create effect "PathFootball" for existing shape from scratch.
SharedPtr<IAutoShape> autoShape1 = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 40, 150, 50);
SharedPtr<IAutoShape> autoShape2 = slide->get_Shapes()->AddAutoShape(ShapeType::Moon, 160, 40, 150, 50);
String alttext = u"User Defined";
int iCount = slide->get_Shapes()->get_Count();
for (int i = 0; i < iCount; i++)
{
// Accessing the added shape
SharedPtr<IShape> shape = slide->get_Shapes()->idx_get(i);
SharedPtr<AutoShape> ashape = DynamicCast<Aspose::Slides::AutoShape>(shape);
if (ashape != nullptr)
{
ashape->set_AlternativeText (u"User Defined " +(i+1));
}
}
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/SetAnchorOfTextFrame_out.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
const String ImagePath = u"../templates/Tulips.jpg";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u"");
ashp->get_FillFormat()->set_FillType(FillType::NoFill);
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
txtFrame->get_TextFrameFormat()->set_AnchoringType ( TextAnchorType::Bottom);
// txtFrame->get_TextFrameFormat()->set_TextVerticalType(TextVerticalType::Vertical270);
// Create the Paragraph object for text frame
SharedPtr<IParagraph> paragraph = txtFrame->get_Paragraphs()->idx_get(0);
// Create Portion object for paragraph
SharedPtr<IPortion>portion = paragraph->get_Portions()->idx_get(0);
portion->set_Text(u"A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.");
portion->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
portion->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/SetAutofitOftextframe_out.pptx";
const String templatePath = u"../templates/DefaultFonts.pptx";
const String ImagePath = u"../templates/Tulips.jpg";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u"");
ashp->get_FillFormat()->set_FillType(FillType::NoFill);
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
txtFrame->get_TextFrameFormat()->set_AutofitType(TextAutofitType::Shape);
// Create the Paragraph object for text frame
SharedPtr<IParagraph> paragraph = txtFrame->get_Paragraphs()->idx_get(0);
// Create Portion object for paragraph
SharedPtr<IPortion>portion = paragraph->get_Portions()->idx_get(0);
portion->set_Text(u"A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.");
portion->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
portion->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/AutomaticSeriesFillColor_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
// Accessing the chart series collection
SharedPtr<IChartSeriesCollection> seriesCollection = chart->get_ChartData()->get_Series();
// Setting the preset number format
// Traverse through every chart series
for (int i = 0; i < seriesCollection->get_Count(); i++)
{
auto series = seriesCollection->idx_get(i);
series->GetAutomaticSeriesColor();
}
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/TestDeck_050.pptx";
const String OutPath = u"../out/ContentBG_Grad_out.pptx";
// Instantiate the Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Apply Gradiant effect to the Background
pres->get_Slides()->idx_get(0)->get_Background()->set_Type(BackgroundType::OwnBackground);
pres->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->set_FillType(FillType::Gradient);
pres->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->get_GradientFormat()->set_TileFlip(TileFlip::FlipBoth);
//Write the presentation to disk
pres->Save(OutPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/TestDeck_050.pptx";
const String OutPath = L"../out/ContentBG_Grad_out.pptx";
// Instantiate the Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Apply Gradiant effect to the Background
pres->get_Slides()->idx_get(0)->get_Background()->set_Type(BackgroundType::OwnBackground);
pres->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->set_FillType(FillType::Gradient);
pres->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->get_GradientFormat()->set_TileFlip(TileFlip::FlipBoth);
//Write the presentation to disk
pres->Save(OutPath, Aspose::Slides::Export::SaveFormat::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 templatePath = L"../templates/SetImageAsBackground.pptx";
const String ImagePath = L"../templates/Tulips.jpg";
const String OutPath = L"../out/ContentBG_Img_out.pptx";
// Instantiate the Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Apply Image as Background
pres->get_Slides()->idx_get(0)->get_Background()->set_Type(BackgroundType::OwnBackground);
pres->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->set_FillType(FillType::Picture);
pres->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->get_PictureFillFormat()->set_PictureFillMode(PictureFillMode::Stretch);
// Get the picture
auto bitmap = MakeObject<System::Drawing::Bitmap>(ImagePath);
// Add image to presentation's images collection
SharedPtr<IPPImage> imgx = pres->get_Images()->AddImage(bitmap);
pres->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->get_PictureFillFormat()->get_Picture()->set_Image(imgx);
//Write the presentation to disk
pres->Save(OutPath, Aspose::Slides::Export::SaveFormat::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 = L"../out/SetSlideBackgroundMaster_out.pptx";
// Instantiate the Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Set the background color of the Master ISlide to Forest Green
pres->get_Masters()->idx_get(0)->get_Background()->set_Type(BackgroundType::OwnBackground);
pres->get_Masters()->idx_get(0)->get_Background()->get_FillFormat()->set_FillType(FillType::Solid);
pres->get_Masters()->idx_get(0)->get_Background()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_ForestGreen());
//Write the presentation to disk
pres->Save(OutPath, Aspose::Slides::Export::SaveFormat::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 = L"../out/SetSlideBackgroundNormal_out.pptx";
// Instantiate the Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Set the background color of the Master ISlide to Forest Green
pres->get_Slides()->idx_get(0)->get_Background()->set_Type(BackgroundType::OwnBackground);
pres->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->set_FillType(FillType::Solid);
pres->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Blue());
//Write the presentation to disk
pres->Save(OutPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/TestDeck_050.pptx";
const String OutPath = u"../out/ContentBG_Grad_out.pptx";
// Instantiate the Presentation class that represents the presentation file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Apply Gradiant effect to the Background
pres->get_Slides()->idx_get(0)->get_Background()->set_Type(BackgroundType::OwnBackground);
pres->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->set_FillType(FillType::Gradient);
pres->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->get_GradientFormat()->set_TileFlip(TileFlip::FlipBoth);
//Write the presentation to disk
pres->Save(OutPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/CategoryAxisLabelDistance_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
// Accessing the chart series collection
SharedPtr<IChartSeriesCollection> seriesCollection = chart->get_ChartData()->get_Series();
// Setting the position of label from axis
chart->get_Axes()->get_HorizontalAxis()->set_LabelOffset ( 500);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/ChartSeriesOverlap_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
// Accessing the chart series collection
SharedPtr<IChartSeriesCollection> seriesCollection = chart->get_ChartData()->get_Series();
auto series = seriesCollection->idx_get(0);
if (series->get_Overlap() == 0)
{
// Setting series overlap
series->get_ParentSeriesGroup()->set_Overlap ( -30);
}
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/SetChildFooter_out.pptx";
SharedPtr<Presentation> presentation = MakeObject<Presentation>();
// Instantiate SlideCollection calss
SharedPtr<ISlideCollection> slds = presentation->get_Slides();
SharedPtr<IMasterSlideHeaderFooterManager> headerFooterManager = presentation->get_Masters()->idx_get(0)->get_HeaderFooterManager();
headerFooterManager->SetFooterAndChildFootersVisibility(true); // Method SetFooterAndChildFootersVisibility is used for making a master slide and all child footer placeholders visible.
headerFooterManager->SetSlideNumberAndChildSlideNumbersVisibility(true); // Method SetSlideNumberAndChildSlideNumbersVisibility is used for making a master slide and all child page number placeholders visible.
headerFooterManager->SetDateTimeAndChildDateTimesVisibility(true); // Method SetDateTimeAndChildDateTimesVisibility is used for making a master slide and all child date-time placeholders visible.
headerFooterManager->SetFooterAndChildFootersText(u"Footer text"); // Method SetFooterAndChildFootersText is used for setting text to master slide and all child footer placeholders.
headerFooterManager->SetDateTimeAndChildDateTimesText(u"Date and time text"); // Method SetDateTimeAndChildDateTimesText is used for setting text to master slide and all child date-time placeholders.
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/SetCustomBulletsNumber_out.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 200, 300);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u"");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
//Clearing exisiting default paragraph
txtFrame->get_Paragraphs()->Clear();
// First list
SharedPtr<Paragraph> paragraph1 = MakeObject<Paragraph>();
paragraph1->set_Text(u"bullet 2");
paragraph1->get_ParagraphFormat()->set_Depth((short)4);
paragraph1->get_ParagraphFormat()->get_Bullet()->set_NumberedBulletStartWith((short)2);
paragraph1->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Numbered);
txtFrame->get_Paragraphs()->Add(paragraph1);
SharedPtr<Paragraph> paragraph2 = MakeObject<Paragraph>();
paragraph2->set_Text(u"bullet 3");
paragraph2->get_ParagraphFormat()->set_Depth((short)4);
paragraph2->get_ParagraphFormat()->get_Bullet()->set_NumberedBulletStartWith((short)3);
paragraph2->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Numbered);
txtFrame->get_Paragraphs()->Add(paragraph2);
// Second list
SharedPtr<Paragraph> paragraph5 = MakeObject<Paragraph>();
paragraph5->set_Text(u"bullet 5");
paragraph5->get_ParagraphFormat()->set_Depth((short)4);
paragraph5->get_ParagraphFormat()->get_Bullet()->set_NumberedBulletStartWith((short)5);
paragraph5->get_ParagraphFormat()->get_Bullet()->set_Type(BulletType::Numbered);
txtFrame->get_Paragraphs()->Add(paragraph5);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String outPath = u"../out/DataLabelsPercentageSign_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::PercentsStackedColumn, 0, 0, 500, 500);
// Set NumberFormatLinkedToSource to false
chart->get_Axes()->get_VerticalAxis()->set_IsNumberFormatLinkedToSource ( false);
chart->get_Axes()->get_VerticalAxis()->set_NumberFormat(u"0.00%");
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();
// Delete default generated series
chart->get_ChartData()->get_Series()->Clear();
// Now, Adding a new series
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 2, ObjectExt::Box<System::String>(u"Series 2")), chart->get_Type());
// Take first chart series
SharedPtr<IChartSeries> series=chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 1, ObjectExt::Box<System::String>(u"Red")), chart->get_Type());
// Now populating series data
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 1, ObjectExt::Box<double>(0.50)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 1, ObjectExt::Box<double>(0.50)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 1, ObjectExt::Box<double>(0.80)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 4, 1, ObjectExt::Box<double>(0.65)));
// Setting fill color for series
series->get_Format()->get_Fill()->set_FillType(FillType::Solid);
series->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Red());
// Setting LabelFormat properties
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true);
series->get_Labels()->get_DefaultDataLabelFormat()->set_IsNumberFormatLinkedToSource ( false);
series->get_Labels()->get_DefaultDataLabelFormat()->set_NumberFormat (u"0.0%");
series->get_Labels()->get_DefaultDataLabelFormat()->get_TextFormat()->get_PortionFormat()->set_FontHeight ( 10);
series->get_Labels()->get_DefaultDataLabelFormat()->get_TextFormat()->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
series->get_Labels()->get_DefaultDataLabelFormat()->get_TextFormat()->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_White());
series->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true);
// Take second chart series
SharedPtr<IChartSeries> series2 = chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 2, ObjectExt::Box<System::String>(u"Blues")), chart->get_Type());
// Now populating series data
series2->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 2, ObjectExt::Box<double>(0.70)));
series2->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 2, ObjectExt::Box<double>(0.50)));
series2->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 2, ObjectExt::Box<double>(0.20)));
series2->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 4, 2, ObjectExt::Box<double>(0.35)));
// Setting fill color for series
series2->get_Format()->get_Fill()->set_FillType(FillType::Solid);
series2->get_Format()->get_Fill()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Blue());
// Setting LabelFormat properties
series2->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true);
series2->get_Labels()->get_DefaultDataLabelFormat()->set_IsNumberFormatLinkedToSource(false);
series2->get_Labels()->get_DefaultDataLabelFormat()->set_NumberFormat(u"0.0%");
series2->get_Labels()->get_DefaultDataLabelFormat()->get_TextFormat()->get_PortionFormat()->set_FontHeight(10);
series2->get_Labels()->get_DefaultDataLabelFormat()->get_TextFormat()->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid);
series2->get_Labels()->get_DefaultDataLabelFormat()->get_TextFormat()->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_White());
series2->get_Labels()->get_DefaultDataLabelFormat()->set_ShowValue(true);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
// The path to the documents directory.
const String templatePath = u"../templates/ExistingChart.pptx";
const String outPath = u"../out/DataRange_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>(templatePath);
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
// SharedPtr<IChart> chart = DynamicCast<Aspose::Slides::Charts::IChart>(slide->get_Shapes()->idx_get(0));
auto chart = DynamicCast<Aspose::Slides::Charts::Chart>(slide->get_Shapes()->idx_get(0));
//Not working
//Set data range
// chart->get_ChartData()->SetRange("Sheet1!A1:B4");
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);
@aspose-com-gists
Copy link
Author

made public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment