Hi friends,
I want to build a asp.net program where resumes in word format will be uploaded and after reading that word file,it will show that in browser like in monster or naukri, where resumes are shown on browser after uploading.But i want to do it without adding any reference of com component.
Please help..
Loading

Vijay YadavRank #1,637 · 943 reputationPosted Mar 17, 2011, 11:44 PM EDT
sanjib mukherjee78 reputationPosted Mar 18, 2011, 1:42 AM EDT
The exact requirement is uploading a resume and displaying that in proper format in browser.
Vijay YadavRank #1,637 · 943 reputationPosted Mar 18, 2011, 1:55 AM EDT
sanjib mukherjee78 reputationPosted Mar 18, 2011, 1:57 AM EDT
Vijay YadavRank #1,637 · 943 reputationPosted Mar 18, 2011, 2:07 AM EDT
sanjib mukherjee78 reputationPosted Mar 18, 2011, 2:12 AM EDT
I am doing all this what you mentioned.Below is the code through which I am trying to read the file and show it but it is reading some junk values also from documents which i am not able to remove.
FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
UTF8Encoding encoding = new UTF8Encoding(true);
StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default);
string str = sr.ReadToEnd();
Can you please help me to remove those junk values.
Vijay YadavRank #1,637 · 943 reputationPosted Mar 18, 2011, 2:36 AM EDT
Vijay YadavRank #1,637 · 943 reputationPosted Mar 18, 2011, 3:15 AM EDT
All you have to do it is to add reference in your application named Microsoft.Office.Interop.Word
and then by using this namspace using Microsoft.Office.Interop.Word;
you can write code for it
for example:
Microsoft.Office.Interop.Word.ApplicationClass Application = new Microsoft.Office.Interop.Word.ApplicationClass();
object nullobj = System.Reflection.Missing.Value;
object file = "Specify path for word file";
Microsoft.Office.Interop.Word.Document doc = Application.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);
doc.Activate();
string Doc_Content = doc.Content.Text;
TextBox1.Text = Doc_Content;
doc.Close(ref nullobj, ref nullobj, ref nullobj);
sanjib mukherjee78 reputationPosted Mar 18, 2011, 3:20 AM EDT
I had set permissions also but still did not work.
Vijay YadavRank #1,637 · 943 reputationPosted Mar 18, 2011, 3:33 AM EDT
sanjib mukherjee78 reputationPosted Mar 18, 2011, 3:55 AM EDT
Can't we do it in any other way,using any lighter process.
I have tried with regex, below is my code:
HTMLCode = HTMLCode.Replace("\r", " ");
HTMLCode = HTMLCode.Replace("\n", " ");
HTMLCode = HTMLCode.Replace("\t", " ");
HTMLCode = HTMLCode.Replace("\0", " ");
HTMLCode = Regex.Replace(HTMLCode, "\\s*", " ");
HTMLCode = Regex.Replace(HTMLCode, @"[^\w\.@-]", "");
// Remove multiple white spaces from HTML
String Pattern="[^a-zA-Z0-9 ]";
Regex oRegex = new Regex(Pattern, RegexOptions.IgnoreCase);
MatchCollection matches = oRegex.Matches(HTMLCode);
//Text = oRegex.Replace(Text, "");
//HTMLCode = oRegex.Replace(Text, "");
//Regex oRegex=new Regex(pattern,RegexOptions.IgnoreCase);
//MatchCollection matches=oRegex.Matches(HTMLCode);
//HTMLCode = oRegex.Replace(HTMLCode, "");
StringBuilder sbHTML = new StringBuilder();
for (int i = 0; i
//if ((HTMLCode[i] >= '0' && HTMLCode[i] <= '9') || (HTMLCode[i] >= 'A' && HTMLCode[i] <= 'z') || (HTMLCode[i] == '.' || HTMLCode[i] == '_'))
//{
// sbHTML.Append(HTMLCode[i]);
//}
Match m = matches[i];
if (m.Success)
{
if (m.Value != "@")
{
HTMLCode = HTMLCode.Replace(m.Value, " ");
}
}
}
But this code also not able to show proper data.Some meta data of word document wth junk values are showing.Is their any pattern in regex which will replace this kind of junk values.Or any other process?
Please help.