Click here to Skip to main content
15,886,592 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a word file in server and i want to display the file in aspx page with out showing contact details in that word file.Please help



i have already converted the word file to html and can view using iframe.But the problem is i dont want to display phone number and email.when iam cheched each string in that html file for specific format(either email or number) that string also includes html code and when it removes the html code also removed.i want to read the substring(only phone number or email) of each string in that html file and remove only that part



C#
    object missingType = Type.Missing;
                    object readOnly = true;
                    object isVisible = false;
                    object documentFormat = 8;
                    object htmlFilePath = Server.MapPath("~/Uploads/Resume/Temp/") + Resume + ".htm";
                    string directoryPath = Server.MapPath("Uploads/Resume/Temp/") + Resume + "_files";

                    object fileName = Server.MapPath("~/Uploads/Resume/" + Resume);//FileUpload1.PostedFile.FileName;

                    //Open the word document in background
                    ApplicationClass applicationclass = new ApplicationClass();
                    applicationclass.Documents.Open(ref fileName,
                                                    ref readOnly,
                                                    ref missingType, ref missingType, ref missingType,
                                                    ref missingType, ref missingType, ref  missingType,
                                                    ref missingType, ref missingType, ref isVisible,
                                                    ref missingType, ref missingType, ref missingType,
                                                    ref missingType, ref missingType);//
                    applicationclass.Visible = false;
                    Document document = applicationclass.ActiveDocument;



                    //Save the word document as HTML file
                    document.SaveAs(ref htmlFilePath, ref documentFormat, ref missingType,
                                    ref missingType, ref missingType, ref missingType,
                                    ref missingType, ref missingType, ref missingType,
                                    ref missingType, ref missingType, ref missingType,
                                    ref missingType, ref missingType, ref missingType,
                                    ref missingType);


 document.Close(ref missingType, ref missingType, ref missingType);

byte[] bytes;
using (FileStream fs = new FileStream(htmlFilePath.ToString(), FileMode.Open, FileAccess.Read))
{
    BinaryReader reader = new BinaryReader(fs);
    bytes = reader.ReadBytes((int)fs.Length);
    fs.Close();
}

 string v="";
string v2 = "";
string value = System.Text.Encoding.UTF8.GetString(bytes);

string[] words = v.Split(' ');
foreach (string word in words)
{
    if (word.Contains("9895843397"))  //this can later be checked using regular expression 
    {
    }
    else
    {
        v2 += word;
    }
}
litResume.Text = v2;
Posted
Updated 9-Jun-14 1:20am
v4
Comments
KaushalJB 9-Jun-14 6:39am    
Without showing contact, Means???
Namith Krishnan E 9-Jun-14 7:12am    
i have already converted the word file to html and can view using iframe.But the problem is i dont want to display phone number and email.when iam cheched each string in that html file for specific format(either email or number) that string also includes html code and when it removes the html code also removed.i want to read the substring(only phone number or email) of each string in that html file and remove only that part
ZurdoDev 9-Jun-14 7:22am    
If I understand you correctly the only way to do that is with string matching and parsing. Manually.
Namith Krishnan E 9-Jun-14 7:43am    
how can i do dat.?Please give code samples
ZurdoDev 9-Jun-14 7:48am    
No. You have to search for specific strings and remove them. Or possibly use RegEx.

1 solution

 
Share this answer
 

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