Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI,
I am reading word file content using open xml.
How can I read related font information using open xml.
Posted

1 solution

check below code
C#
Stream stream = File.Open(@"test.docx", FileMode.Open);
WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(stream, true);
// read document content
string wordcontent = wordprocessingDocument.MainDocumentPart.Document.Body.InnerText;
// get all fonts of the word document 
var fonts = wordprocessingDocument.MainDocumentPart.Document.Descendants<runfonts>().Select(c => c.Ascii.HasValue ? c.Ascii.InnerText : string.Empty).Distinct().ToList();</runfonts>


ref:
http://ybbest.wordpress.com/2011/06/29/retrieve-the-content-of-microsoft-word-document-using-openxml-and-c/[^]
http://stackoverflow.com/questions/5261108/list-fonts-used-by-a-word-document-faster-method[^]
 
Share this answer
 
Comments
RhishikeshLathe 6-May-14 6:50am    
thanks for ur answer,
sorry for late reply.
I want to read word line & its font style.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900