Aspose.Slides for C++
探索Aspose.Slides for C++优势,实现跨平台PowerPoint处理,支持多种格式转换与高效演示文稿操作,提升开发效率。
将演示文稿保存到文件或流
将演示文稿转换为标准格式
管理内置和自定义文档属性
密码保护演示文稿
添加、格式化和操作图表
添加、格式化和操作形状
添加、格式化和操作幻灯片
添加、格式化和处理文本
添加、格式化和操作表格
将演示文稿导出为 PDF 和 XPS
以 SVG 格式导出幻灯片
向演示文稿添加图像
将演示文稿导出为视频
向演示文稿添加信息图表
从数据库生成演示文稿
支持 MSO 2016 图表
将演示文稿导出为 HTML
在幻灯片中导入和导出 HTML 文本
向演示文稿添加布局幻灯片
加载受保护的演示文稿
设置单个图例的字体大小
创建股票图表并获取图表图像
更改系列颜色
设置图表区圆角边框
更改系列中类别的颜色
设置图表数据表的字体属性
Aspose.Slides for C++ 可以处理多种 PowerPoint 演示文稿文件格式,例如:
您还可以将演示文稿与流和字节数组相互转换。
Aspose.Slides for C++ 是一个功能强大的 C++ 库,用于创建和处理演示文稿文件。此外,它还提供了灵活的演示文稿转换为 PDF 的方法。使用Aspose.Slides for C++,任何开发人员或应用程序只需几行 C++ 代码即可将 Powerpoint 演示文稿转换为 PDF 文件。
// Load the PPT. SharedPtr<Presentation> presentation = MakeObject<Presentation>(u"presentation.ppt"); // Save in PDF format. presentation->Save(u"document.pdf", Aspose::Slides::Export::SaveFormat::Pdf);
在演示元素中添加动画可以使其更具互动性并吸引观众。
// Instantiates a presentation class that represents a presentation file. System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(); System::SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0); // Adds new AutoShape with text System::SharedPtr<IAutoShape> autoShape = sld->get_Shapes()->AddAutoShape(Aspose::Slides::ShapeType::Rectangle, 20.0f, 20.0f, 150.0f, 100.0f); System::SharedPtr<ITextFrame> textFrame = autoShape->get_TextFrame(); textFrame->set_Text(u"First paragraph \nSecond paragraph \n Third paragraph"); // Gets the main sequence of the slide. System::SharedPtr<ISequence> sequence = sld->get_Timeline()->get_MainSequence(); // Adds Fade animation effect to shape System::SharedPtr<IEffect> effect = sequence->AddEffect(autoShape, Aspose::Slides::Animation::EffectType::Fade, Aspose::Slides::Animation::EffectSubtype::None, Aspose::Slides::Animation::EffectTriggerType::OnClick); // Animates shape text by 1st level paragraphs effect->get_TextAnimation()->set_BuildType(Aspose::Slides::Animation::BuildType::ByLevelParagraphs1); // Save the PPTX file to disk pres->Save(path + u"AnimText_out.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
在某些情况下,可能需要将整个演示文稿转换为图像集合,这可以使用Aspose.Slides for C++来实现。
将演示文稿转换为一组图像有很多好处。例如,它可以帮助减小演示文稿的文件大小,使其更易于共享和存储。此外,它还可以确保演示文稿在不同设备和平台上的显示效果一致。当您想在不支持 PowerPoint 文件的文档或网页中添加幻灯片时,将演示文稿转换为图像也非常有用。最后,当您想将演示文稿制作成视频时,将演示文稿转换为图像也非常有用。
C++ 代码演示了如何将演示文稿转换为 JPG 图像。
auto pres = System::MakeObject<Presentation>(u"PowerPoint-Presentation.pptx"); // Defines dimensions int32_t desiredX = 1200, desiredY = 800; // Gets scaled values 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; for (auto&& sld : pres->get_Slides()) { // Creates a full scale image System::SharedPtr<System::Drawing::Bitmap> bmp = sld->GetThumbnail(ScaleX, ScaleY); // Saves the image to disk in JPEG format bmp->Save(System::String::Format(u"Slide_{0}.jpg", sld->get_SlideNumber()), System::Drawing::Imaging::ImageFormat::get_Jpeg()); }
可以使用Aspose.Slides for C++ API将 PowerPoint 演示文稿转换为视频
将演示文稿转换为视频格式有诸多益处。首先,它使演示文稿更容易被更广泛的受众接受,因为视频可以在各种设备和平台上播放,而无需 PowerPoint 软件。其次,视频比 PowerPoint 文件更易于分享,因为它们可以上传到 YouTube 等视频分享平台。第三,视频可以嵌入网站和博客,从而更轻松地与更多受众分享演示文稿。第四,视频可以用于培训,因为它们可以暂停和倒回以查看演示文稿的特定部分。最后,视频可以通过添加动画、过渡和背景音乐,使演示文稿更具吸引力。
void OnFrameTick(System::SharedPtr<PresentationPlayer> sender, System::SharedPtr<FrameTickEventArgs> args) { System::String fileName = System::String::Format(u"frame_{0}.png", sender->get_FrameIndex()); args->GetFrame()->Save(fileName); } void Run() { auto presentation = System::MakeObject<Presentation>(u"PowerPoint-Presentation.pptx"); const int32_t fps = 33; auto animationsGenerator = System::MakeObject<PresentationAnimationsGenerator>(presentation); auto player = System::MakeObject<PresentationPlayer>(animationsGenerator, fps); player->FrameTick += OnFrameTick; animationsGenerator->Run(presentation->get_Slides()); const System::String ffmpegParameters = System::String::Format( u"-loglevel {0} -framerate {1} -i {2} -y -c:v {3} -pix_fmt {4} {5}", u"warning", m_fps, "frame_%d.png", u"libx264", u"yuv420p", "video.mp4"); auto ffmpegProcess = System::Diagnostics::Process::Start(u"ffmpeg", ffmpegParameters); ffmpegProcess->WaitForExit(); }