asp.net - How to open varbinary word doc as HTML -


i have problem have not been able find answer in months. store word doc resumes varbinary(max). can retrieve resumes based on full-text search – no problem. resumes retrieved word documents in .ashx file following code. need implement hit highlighting on site users can see if returned resume fit or not. don’t think can done .ashx file, think need able open resume html in aspx page , maybe use javascript hit highlighting or perhaps return text content of word document somehow , manipulate text before display html tags. cant find anywhere addresses problem. hoping can point me in right direction.

thanks in advance advice.

imports system.io imports system.web imports system.data imports system.data.sqlclient     public class readresume : implements ihttphandler  const constring string = "data source=tcp:sql2k804.discountasp.net;initial catalog=sql2008r2_284060_resumedata;user id=sql2008r2_284060_resumedata_user;password=mypwd2314;"  public sub processrequest(byval context httpcontext) implements ihttphandler.processrequest  dim con sqlconnection = new sqlconnection(constring)  dim cmd sqlcommand = new sqlcommand("select resumedoc, doctypeextension resumetable candidateid=@candidateid", con)  dim cid string = system.web.httpcontext.current.request.querystring("para") cmd.parameters.addwithvalue("@candidateid", cid)  using con con.open() dim myreader sqldatareader = cmd.executereader if myreader.read()    context.response.clear()    context.response.clearcontent()    context.response.clearheaders()    dim file() byte = ctype(myreader("resumedoc"), byte())    dim doc_type string = ctype(myreader("doctypeextension"), string)    context.response.contentencoding = system.text.encoding.utf8    context.response.contenttype = "application/msword"    context.response.addheader("content-disposition", "candidate resume")    context.response.binarywrite(file) end if  end using  end sub    public readonly property isreusable() boolean implements ihttphandler.isreusable   return false  end  end property    end class 

you can use microsoft office com components deal word documents. example, way convert word html: http://rongchaua.net/blog/c-convert-word-to-html/

update: there other solutions.

if have .docx (not .doc) documents can use simple code extract plain text docx documents: http://www.codeproject.com/kb/office/extracttextfromdocxs.aspx same code: http://conceptdev.blogspot.com/2007/03/open-docx-using-c-to-extract-text-for.html

there commercial libraries reading/writing word documents: http://www.aspose.com/categories/.net-components/aspose.words-for-.net/default.aspx http://www.cellbi.com/products.aspx


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -