We are using Windward to generate reports in Microsoft Word.
Due to some update, Unicode Characters are no longer displaying properly.
While the vendor is still looking for a fix, we're looking for a work around.
One Symptom that I've noticed is that the "Normal" style does not appear in the "Styles Gallery" on the Ribbon.
I can find it in the "styles.xml" part of the file. I noticed that the style does not have a RSID associated with it, the way a normal MS Word file would.
GOOD FILE "Normal" style appears in Gallery
<w:style w:type="paragraph" w:styleId="Normal" w:default="1">
<w:name w:val="Normal" />
<w:qFormat />
<w:rsid w:val="003C4F1E" />
</w:style>
BAD FILE "Normal" style does NOT appear in Gallery
<w:style w:type="paragraph" w:default="1" w:styleId="Normal">
<w:name w:val="Normal"/>
</w:style>
Modifying the the Styles.xml file so that the "Normal" style would have rsid as well as qFormat xml tags fixed the issue of getting the "Normal" style to appear in the Gallery.
What I noticed was that once I had the "Normal" reappear and I clicked it without first having to select any text in the document, the Unicode Characters would display correctly.
When I checked document.xml I noticed that the following xml was added before the run:
<w:rPr>
<w:rFonts w:ascii="Mangal" w:hAnsi="Mangal" w:cs="Mangal"/>
</w:rPr>
How did MS Word know to select those values for the runPoperty?
How can I use ooxml to detect Complex script and then make the appropriate font selection?
SAMPLE XML USING COMPLEX SCRIPT
<w:r>
<w:rPr>
<w:rFonts w:ascii="Mangal" w:hAnsi="Mangal" w:cs="Mangal"/>
</w:rPr>
<w:t>एनडीटीवी</w:t>
</w:r>
What I have so far.
static bool GetRunText()
{
bool bStylesFound = false;
using (WordprocessingDocument doc = WordprocessingDocument.Open(_path, false))
{
// Get a reference to the main document part.
var docPart = doc.MainDocumentPart;
// Get the first paragraph.
Paragraph p = docPart.Document.Body.Descendants<Paragraph>().ElementAtOrDefault(0);
if (p == null)
{
Console.WriteLine("No paragraphs found.");
}
else
{
Run run = p.Descendants<Run>().ElementAtOrDefault(1);
RunProperties rp = run.RunProperties;
//Console.WriteLine(rp.RunFonts.);
bStylesFound = true;
}
return bStylesFound;
}
}