c# - Open xml cannot get a drawing element -
i going through docx, uscing open xml find images.
so, doing drawings, got docproperties child, title containing
list<drawing> sdtelementdrawing = worddoc.maindocumentpart.document.descendants<drawing>() .where(element => element.getfirstchild<drawing>() != null && element.getfirstchild<docproperties>().title.value.contains("image")).tolist();
and docx xml looks likes in first part(it bigger, copy relevant part) :
<w:drawing> <wp:anchor distt="0" distb="0" distl="114300" distr="114300" simplepos="0" relativeheight="251658240" behinddoc="1" locked="0" layoutincell="1" allowoverlap="1" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingdrawing"> <wp:simplepos x="0" y="0" /> <wp:positionh relativefrom="column"> <wp:posoffset>2171700</wp:posoffset> </wp:positionh> <wp:positionv relativefrom="paragraph"> <wp:posoffset>-1168400</wp:posoffset> </wp:positionv> <wp:extent cx="2286000" cy="746760" /> <wp:effectextent l="0" t="0" r="0" b="0" /> <wp:wrapnone /> <wp:docpr id="1" name="image 1" descr="c:\users\pictures\imagerm.jpg" title="imagerm" /> </wp:anchor> </w:drawing>
but don't find sdtelementdrawing
.
so think miswrote sdtelementdrawing
query. must miss obvious way tell "get drawing child, there docproperties title image", cannot find it.
i tried this, doesn't work better :
list<drawing> sdtelementdrawing = worddoc.maindocumentpart.document.descendants<drawing>() .where(element => element.getfirstchild<drawing>() != null && element.getfirstchild<drawing>().anchor.getfirstchild<docproperties>().title.value.contains("image")).tolist();
have tried one?
list<drawing> sdtelementdrawing = worddoc.maindocumentpart.document.descendants<drawing>() .where(element => element.descendants<docproperties>().any( prop => prop.title.value.toupper().contains("image") )).tolist();
Comments
Post a Comment