Quantcast
Channel: Open XML Format SDK forum
Viewing all articles
Browse latest Browse all 1288

C# openxml sdk convert all wmf and emf images found in a docx into png and replace the occurences in all corresponding xmls.

$
0
0

I am using openxml sdk to read and manipulate docx.

I am able to iterate through all the images found in a docx and my task is to replace all the wmf/emf images into png or jpg.

string sourceFile="@D:\temp\sample.docx";
using (WordprocessingDocument myDocument = WordprocessingDocument.Open(sourceFile, true))
{
 var imageParts = myDocument.MainDocumentPart.ImageParts;
 foreach (ImagePart imagePart in imageParts)
 {
   var uri = imagePart.Uri;
   var filename = uri.ToString().Split('/').Last();
   if (imagePart.ContentType.Equals("image/x-wmf"))
   {
      Image img = Image.FromStream(imagePart.GetStream());
      /*
        Now I need to convert the image format from WMF or
        EMF to PNG and replace the output in all the xml.
      */
   }

 }
}


Viewing all articles
Browse latest Browse all 1288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>