Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to display ms word document in asp.net, but I want to display word as it is in original format ... Means with spaces and each line should be dislplay in new line

I have tried this but their are no spaces between words
C#
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();

string filePath = path;
object file = filePath;
object nullobj = System.Reflection.Missing.Value;

Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref file, ref nullobj, ref nullobj,

       ref nullobj, ref nullobj, ref nullobj,

        ref nullobj, ref nullobj, ref nullobj,

        ref nullobj, ref nullobj, ref nullobj,

        ref nullobj, ref nullobj, ref nullobj, ref nullobj);  

Microsoft.Office.Interop.Word.Document doc1 = wordApp.ActiveDocument;
Range m_Content = doc1.Content.FormattedText;

Label3.Text =m_Content.text;
doc.Close(ref nullobj, ref nullobj, ref nullobj);

My Output is display as
Resume Name:-Raju Bhaiyyalal Khangare E-Mail id :-rajukhangare2211@gmail.com    Contact no. :-8793166274 Carrier Objective:-    To build my self in fast growing IT field & provide best of services to the organization, with hard work and skill which will take me to the pinnacle while contributing to the growth of the organization. Personal Skills:- Creative and positive mindset. Work with devotion and give my 100% at worktime. Efficient and effective in prioritizing work well under pressure . Educational Details:- Course University/Board Passing Year Percentage  S.S.C. Pune Board 2007 72%  H.S.C Pune Board 2009 74%  B.C.A RTM Nagpur University  2012 47.11%  M.C.A.-II RTM Nagpur University  2013  (Appeared)   Computer Skills:-     JAVA VB HTML Oracle MS-OFFICE 03/07 Windows vista/xp/07,Unix,DOS Curricular Activities:- UR of RCC college for 2 years Organized Gathering in RCC college Other Courses :- Done diploma in Core and Advance java programming Done diploma in VB     Done diploma in computer application from RSMIT Personal Details:- Name     :Raju Khangare Father’s Name    :Bhaiyyalal Bhagwan Khangare Address    :At post Saoner,Near Radheshyam Temple, Ward No.16 , Pahlepar Saoner,Dist.-Nagpr State-     Maharashta Date Of Birth    :22 october 1991 Gender     :Male Nationality   :Indian Language Known :Hindi,Marathi,English   Hobbies     :Chess ,Cricket, Music, travelling Declaration:- I here by declare that above mentioned information is true to the best of my knowledge. Date;-     Raju khangare Place:-

Plz help me.
Posted
v2

Just try Google Doc Viewer. It's very simple to use, free & you do not need any external tool nor dll! Add a markup code like the following in your webpage:

HTML
<iframe src="http://docs.google.com/gview?url=URL-TO-YOUR-DOC-FILE&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>


Just set "url" query string param to your Word doc file as an absolute URI and that's it!
 
Share this answer
 
Comments
Valery Possoz 24-Oct-13 16:08pm    
good to know :)
Well, in the word file there is no <br/> tag. Newline sequences are irrelevant to the browser, they won't break the rows.
You should take m_Content.text and replace all "\r\n" sequences with "<br/>".
This stands also for the spaces. The browser is ignoring repeated spaces "    " will render only " ". You could replace spaces with &nbsp; entities, but be aware, these are non-breaking spaces.

Ok, this is a really minimalist way of showing that data, but this was your question.
 
Share this answer
 
v4
Comments
thatraja 24-Oct-13 8:13am    
5!

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