net core 将 ppt文件 转 图片文件
您可以使用Aspose.Slides for .NET来将PPT文件转换为图像文件。以下是一个示例代码:
using Aspose.Slides.Export;
// Load the PPT file
using (var presentation = new Presentation("Presentation.ppt"))
{
// Define the image options
var imageOptions = new ImageOptions
{
Format = ImageFormat.Png,
Quality = 100
};
// Export each slide as a separate image file
for (int i = 0; i < presentation.Slides.Count; i++)
{
using (var imageStream = new MemoryStream())
{
// Save the slide as an image
presentation.Slides[i].Save(imageStream, SlideExportFormat.Png, imageOptions);
// Save the image file
using (var fileStream = new FileStream($"Slide{i + 1}.png", FileMode.Create))
{
imageStream.WriteTo(fileStream);
}
}
}
}
此代码将在当前目录下创建一个名为 "Slide1.png"、"Slide2.png" 等的图像文件,对应于PPT文件中的每个幻灯片。您可以根据需要更改图像格式、质量和输出路径
原文地址: https://www.cveoy.top/t/topic/fIua 著作权归作者所有。请勿转载和采集!