从 powerpoint 文件中检索图像名称
我需要从 pptx 文件中的图像中检索图像文件名。我已经从图像中获取了流,但我没有得到图像文件的名称...这是我的代码:
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;
}
有人知道我如何完成此操作吗? 谢谢!!
I need to retrieve the image file name from an image in a pptx file. I already got the stream from the image but i didn't got the name of the image file... Here is my code:
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;
}
Anyone knows how i can accomplish this ?
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,pptx 文件中的图片/图像有两个文件名:
如果您需要嵌入在 pptx 文件中的图像的文件名
您可以使用以下函数:
如果您需要图像的原始文件系统名称,您可以使用以下函数:
BEGIN EDIT:
以下是完整的代码示例:
END EDIT >
希望这会有所帮助。
There are in fact two file names for a picture/image in a pptx file:
If you need the file name of the image as it is embedded in the pptx file
you can use the following function:
If you need the orignial file system name of your image you can use the following function:
BEGIN EDIT:
Here is a complete code example:
END EDIT
Hope, this helps.