Dankwansere 0 Newbie Poster

Hey guys,
I've struggling to implement this solution for about a week now. We are using word templates that have inline shapes drawn inside. The inline shapes are used as a place holder to programatically insert image bar codes into the document. Previously we were using Ms.Interop.dll libraries to achieve this task, But we found out Microsoft doesn't recommend using MS.Interop libraries on server side and they instead suggest using OpenXML.

Using MS.Interop libraries we were able to do this with just a few lines of code shown below

foreach (Shape shape in aDoc.Shapes)
                {
                    if (shape.Type == Microsoft.Office.Core.MsoShapeType.msoAutoShape &&
                        shape.AutoShapeType == Microsoft.Office.Core.MsoAutoShapeType.msoShapeRoundedRectangle)
                    {
                        object range = shape.TextFrame.TextRange;
                        InlineShape barcodeShape = aDoc.InlineShapes .AddPicture(barcodeFilePath, ref FALSE, ref TRUE, ref range);
                        shape.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;


                    }
                }

I've searched thoroughly online to see if this is possible with openXML but so far have found nothing, Only thing i've found is a way to insert images into a document, but I want the image in a specific position inside a shape..is this possible in openXML SDK 2.5?