Join
Sign in
Search Options
Search Everything
Search Development Tools
Home
Blog
Resources
Forums
About Open XML
More ...
Home
»
Forums
»
Development Tools
»
.Net
»
Get image info with c#?
Get image info with c#?
Development Tools
Discussions about working with Open XML using a wide range of development tools
Get this RSS feed
Details
2
Replies
2
Subscribers
Posted
over 2 years ago
Options
Subscribe via RSS
Share this
.Net
Get image info with c#?
rated by 0 users
This post has
2 Replies |
2
Followers
mark_stevo
20
Posted by
mark_stevo
on
Wed, Jun 30 2010 5:22 AM
rated by 0 users
Post Points: 20
Get image info with c#?
Hi, I'm new to openXML so go easy on me!
Here is a snippet from a docx file I have
<w:drawing>
<wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="1352550" cy="1800225"/>
<wp:effectExtent l="19050" t="0" r="0" b="0"/>
<wp:docPr id="1" name="Picture 1" descr="Catherine Adams Photo"/>
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="0" name="Picture 1" descr="A Person Photo"/>
<pic:cNvPicPr>
<a:picLocks noChangeAspect="1" noChangeArrowheads="1"/>
</pic:cNvPicPr>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId6" cstate="print"/>
<a:srcRect/>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr bwMode="auto">
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="1352550" cy="1800225"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
<a:noFill/>
<a:ln w="9525">
<a:noFill/>
<a:miter lim="800000"/>
<a:headEnd/>
<a:tailEnd/>
</a:ln>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
The docx has many images, this is just one. Using MainDocumentPart.ImageParts I can get all the ImageParts but I need to be able to get the "<pic:cNvPr id="0" name="Picture 1" descr="A Person Photo"/>" details, specifically the descr attribute. How do I go about this?
Intergen
2610
Posted by
Intergen
on
Wed, Jul 14 2010 8:08 PM
rated by 0 users
Post Points: 20
Re: Get image info with c#?
I don't think you can get the description data you need from the ImageParts collection.
I would suggest using Linq to find all of the
NonVisualDrawingProperties
in the body of the document. Like this:
var drawingPropertiess = wordprocessingDocument.MainDocumentPart.Document.Body.Descendants().Where(openXmlElement => openXmlElement is DocumentFormat.OpenXml.Drawing.Pictures.NonVisualDrawingProperties);
var photoDescriptions = drawingPropertiess.Select(drawingProp => ((DocumentFormat.OpenXml.Drawing.Pictures.NonVisualDrawingProperties)drawingProp).Description);
This will give you an IEnumerable
photoDescriptions
of every description.
gkochanowsky
5
Posted by
gkochanowsky
on
Wed, May 25 2011 3:30 PM
rated by 0 users
Post Points: 5
Re: Get image info with c#?
^^^^^ This doesn't work.
Page 1 of 1 (3 items)