Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get text from word using DocumentFormat.OpenXml

I am trying to get text from .docx file and when use this code in visual studio it's working well but when uploading to server I get the error:

Error: Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true)) {
    DocumentFormat.OpenXml.Wordprocessing.Body body
        = wordDoc.MainDocumentPart.Document.Body;
    totaltext = body.InnerText;
}
like image 879
Eng Mohamed Attian Avatar asked Oct 14 '25 04:10

Eng Mohamed Attian


1 Answers

You must register the dll "DocumentFormat.OpenXml.dll" on each machine you want to use your code.

Register the dll on the server and it should works just fine

like image 79
Maxime Porté Avatar answered Oct 17 '25 23:10

Maxime Porté



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!