Free Support Forum - aspose.com

Changing languge in wordML

Hello,
Iam trying to convert my word to xml, everything is fine but the font is not saved. Iam using “David” font and getting “Times New Roman”

If you look at the xml file attached you can see it includes the following line:
<w:font w:name=“Times New Roman”>

Iam trying to change it in my code… how can I change/add elements at the xml file?
and how can I save the word as Word 2003 XML Document?

public void Post()
        {
            var file = HttpContext.Current.Request.Files.Count > 0 ? 
                           HttpContext.Current.Request.Files[0] : null;

            MemoryStream xmlStream = new MemoryStream();

            using (MemoryStream docStream = new MemoryStream())
            {
                file.InputStream.CopyTo(docStream);
                file.InputStream.Dispose();

                Document xml = new Document(docStream);
                xml.Save(xmlStream, SaveFormat.WordML);

                string xmlText = Encoding.UTF8.GetString(xmlStream.GetBuffer());
                xmlText = xmlText.Replace("Times New Roman", "David");

                xmlStream = new MemoryStream();
                var writer = new StreamWriter(xmlStream);
                writer.Write(xmlText);
                writer.Flush();
                xmlStream.Position = 0;
                xml.Save(@"C:\Users\Puno\Desktop\file.xml", SaveFormat.WordML);
            }
        }

here is the word iam converting from and the xml iam getting
Desktop.zip (11.3 KB)

@Jopa,

Have you embedded this Font in DOCX file? Please also ZIP and upload ‘David’ font file here for further testing.

I just have this font in my word…
anyway I attached the font
david.zip (35.7 KB)

@Jopa,

We have installed the font on our end. But, I am afraid, we still do not see any font difference in Aspose.Words generated XML file on our end (see screenshot). We are using MS Word 2016 for viewing DOCX and XML documents on our end.

Can you please list steps that help us to reproduce the same issue on our end?