Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert images in a docx with Open xml

Status
Not open for further replies.

GSharp69

Programmer
Jan 27, 2008
9
BE
Hi

i have tried to put images in a docx with open xml
he creates the docx but no images are shown in the document

i use this code to put images:

Code:
PackagePart partPicture = document.CreatePart(packageOutput, uriPicture, "image/jpeg");

            using (Stream targetStream = partPicture.GetStream()) 
            {
                using (FileStream sourceStream = new FileStream(@"c:\Joker2.jpg",FileMode.Open, FileAccess.Read))
                {
                    byte[] buffer = new byte[1024];
                    int nrBytesWritten = sourceStream.Read(buffer, 0, 1024);
                    while (nrBytesWritten > 0)
                    {
                        targetStream.Write(buffer, 0, nrBytesWritten);
                        nrBytesWritten = sourceStream.Read(buffer, 0, 1024);
                    }
                }
            }

grtz

GSharp69
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top