Skip to content
Loading
How to preview the PDF document and Search the words  
  •   
  •   
  •   
  • CS file and this for word document(office)..
    1. namespace WordDocumentLoadSampleWebApp  
    2. {  
    3. public partial class LoadingWordDocument : System.Web.UI.Page  
    4. {  
    5. protected void Page_Load(object sender, EventArgs e)  
    6. {  
    7. }  
    8. protected void btnUpload_Click(object sender, EventArgs e)  
    9. {  
    10. object documentFormat = 8;  
    11. string randomName = DateTime.Now.Ticks.ToString();  
    12. object htmlFilePath = Server.MapPath("~/Temp/") + randomName + ".htm";  
    13. string directoryPath = Server.MapPath("~/Temp/") + randomName + "_files";  
    14. object fileSavePath = Server.MapPath("~/Temp/") + Path.GetFileName(FileUpload1.PostedFile.FileName);  
    15. //If Directory not present, create it.  
    16. if (!Directory.Exists(Server.MapPath("~/Temp/")))  
    17. {  
    18. Directory.CreateDirectory(Server.MapPath("~/Temp/"));  
    19. }  
    20. //Upload the word document and save to Temp folder.  
    21. FileUpload1.PostedFile.SaveAs(fileSavePath.ToString());  
    22. //Open the word document in background.  
    23. _Application applicationclass = new Application();  
    24. applicationclass.Documents.Open(ref fileSavePath);  
    25. applicationclass.Visible = false;  
    26. Document document = applicationclass.ActiveDocument;  
    27. //Save the word document as HTML file.  
    28. document.SaveAs(ref htmlFilePath, ref documentFormat);  
    29. //Close the word document.  
    30. document.Close();  
    31. //Read the saved Html File.  
    32. string wordHTML = System.IO.File.ReadAllText(htmlFilePath.ToString());  
    33. //Loop and replace the Image Path.  
    34. foreach (Match match in Regex.Matches(wordHTML, "", RegexOptions.IgnoreCase))  
    35. {  
    36. wordHTML = Regex.Replace(wordHTML, match.Groups[1].Value, "Temp/" + match.Groups[1].Value);  
    37. }  
    38. dvWord.InnerHtml = wordHTML;  
    39. }  
    40. }  
  • Sanjay Gangurde
    Please find below HTML code,
     
    Title of the document

    PDF Example with iframe

     
    You can use same in Master page and Content Page