2
我需要一个PPTX文件从图像检索图像文件名检索图像名称。我已经得到了从图像的流,但我没有得到的图像文件的名称...这里是我的代码:从PowerPoint文件
private static Stream GetParagraphImage(DocumentFormat.OpenXml.Presentation.Picture picture, DocumentFormat.OpenXml.Packaging.PresentationDocument presentation, ref MyProject.Import.Office.PowerPoint.Presentation.Paragraph paragraph)
{
// Getting the image id
var imageId = picture.BlipFill.Blip.Embed.Value;
// Getting the stream of the image
var part = apresentacao.PresentationPart.GetPartById(idImagem);
var stream = part.GetStream();
// Getting the image name
var imageName = GetImageName(imageId, presentation);
/* Here i need a method that returns the image file name based on the id of the image and the presentation object.*/
// Setting my custom object ImageName property
paragraph.ImageName = imageName;
// Returning the stream
return stream;
}
任何人都知道我是如何做到这一点? 谢谢!
嗨,谢谢你的答案,但属性NonVisualDrawingProperties不直接存在的图片对象...首先,我需要检索NonVisualPictureProperties然后NonVisualDrawingProperties.Description,但是当我访问此属性时,她返回null ...有是一些使用或其他任何我需要键入之前? –
@ mnatan.brito:你说得对。 NonVisualDrawingProperties属性不直接存在于图片类中。我用更完整的代码示例更新了我的答案。我已经再次运行了一个power point 2007文档,它打印了原始文件名。希望这可以帮助。 – Hans
描述属性为所有图像返回null在PPTX ... –