c# - how i Fetch text from files on server? -


have web application cv uploading want fetch text during uploading have 2 types of cvs (word & pdf ) using itextsharp && microsoft.office.interop.word , works fine on server not working

 string mainer(string pathfile)         {           microsoft.office.interop.word.application word = new microsoft.office.interop.word.application();          string totaltext = "";         try         {              object miss = system.reflection.missing.value;             // object truee = true;             object otrue = false;             object path = pathfile;             object readonly = true;             object pass = "";             microsoft.office.interop.word.document docs = word.documents.open(ref path, ref miss, ref readonly, ref miss, pass, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref otrue, ref miss, ref miss, ref miss, ref miss);              (int = 0; < docs.paragraphs.count; i++)             {                 totaltext += " \r\n " + docs.paragraphs[i + 1].range.text.tostring();             }              docs.close();              word.quit();              word = null;             docs = null;             gc.collect();             return totaltext;         }         catch (exception e)         {              //((_document)word).close();             //((_application)word).quit();             word.quit();              word = null;              //ererorcount = ererorcount + 1;             //listerrors.add(pathfile);              return totaltext;              //   return ererorcount.tostring();         }       } 

error is

error: retrieving com class factory component clsid {000209ff-0000-0000-c000-000000000046} failed due following error: 80070005 access denied. (exception hresult: 0x80070005 (e_accessdenied)).

microsoft not recommend, , not support, automation of microsoft office applications unattended, non-interactive client application or component (including asp, asp.net, dcom, , nt services), because office may exhibit unstable behavior and/or deadlock when office run in environment.

if building solution runs in server-side context, should try use components have been made safe unattended execution. or, should try find alternatives allow @ least part of code run client-side. if use office application server-side solution, application lack many of necessary capabilities run successfully. additionally, taking risks stability of overall solution. read more in considerations server-side automation of office article.

you may consider using open xml sdk or other third party componets designed server-side execution. see welcome open xml sdk 2.5 office more information.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -