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 ... –