我有以下代码从PowerPoint文件中提取和保存图像:
public static void GetImages()
{
var doc = PresentationDocument.Open(@"D:\Peak Sourcing\Work\ppt_test\presenting.ppt", true);
var presentationPart = doc.PresentationPart;
var slidePart = presentationPart.GetPartsOfType<SlidePart>().FirstOrDefault();
var imagePart = slidePart.GetPartsOfType<ImagePart>().FirstOrDefault();
var stream = imagePart.GetStream();
var img = Image.FromStream(stream);
img.Save(@"D:\Peak Sourcing\Work\ppt_test\test-output.png");
}
但是,最后一行中使用的类Image
不存在。这是我在程序中包含的名称空间:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Text;
using System.IO;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Presentation;
using DocumentFormat.OpenXml.Packaging;
using System.Drawing;
如何解决这个问题?