Unable to retrieve all text from Word document

Hi. I’m trying to retrieve plain text from the attached Word document. Some of the text is retrieved but not all (see attachment for results). I’m using Words.NET 14.10.0.0 and I’ve tried both and the document.GetText() method and the document.Range.Text property with similar results.

Any suggestions?

Thanks.

Hi Lars,

Thanks for your inquiry. I have tested the scenario using Aspose.Words for .NET 14.11.0 and have not found the shared issue. Please use Aspose.Words for .NET 14.11.0.

Please note
that in evaluation mode there are some limitations applied. To avoid this you can request a free 30-day
trial license which removes these evaluation restrictions. You can
request this from here:
https://purchase.aspose.com/temporary-license

Hi Tahir.
Thanks for your response.

I have just downloaded v14.11.0 and tried out my simple test case. Unfortunately the results are still the same (as included in the previous file text_from_test.txt

What results are you able to retrieve from the file? Could you extract the 6 sections of text (e.g. “SYFTE OCH
OMFATTNING”) included in the word file test.doc

Thank you.

Hi Lars,

Thanks for your inquiry. I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-11254. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

As a workaround, please use Section.ToString method as shown below to get the required output.

Document doc = new Document(MyDir + "test.doc");
foreach (Section section in doc.Sections)
{
    Console.WriteLine(section.ToString(SaveFormat.Text));
}

Hi. Any word on when this issue will be resolved?
The recommended workaround is good, but not good enough since it does not cover headers, footers, etc. It would be quite tedious to write code that covers all parts of a document.

Cheers.

Hi Lars,

Thanks for your inquiry. I would like to share with you that issues
are addressed and resolved based on first come first serve
basis. Currently, your issue is pending for analysis and is in the queue. I am afraid, we can’t provide you any reliable estimate at the
moment. Once your issue is analyzed, we will then be able to provide you
an estimate. Thanks for your patience and understanding.

Please try following workaround for this issue. Hope this helps you.

Document doc = new Document(MyDir + "test(2).doc");
foreach (Section section in doc.Sections)
{
    foreach (HeaderFooter header in section.HeadersFooters)
    {
        if (header.HeaderFooterType == HeaderFooterType.HeaderPrimary ||
        header.HeaderFooterType == HeaderFooterType.HeaderFirst ||
        header.HeaderFooterType == HeaderFooterType.HeaderEven)
            Console.WriteLine(header.ToString(SaveFormat.Text));
    }
    Console.WriteLine(section.ToString(SaveFormat.Text));
    foreach (HeaderFooter header in section.HeadersFooters)
    {
        if (header.HeaderFooterType == HeaderFooterType.FooterPrimary ||
        header.HeaderFooterType == HeaderFooterType.FooterFirst ||
        header.HeaderFooterType == HeaderFooterType.FooterEven)
            Console.WriteLine(header.ToString(SaveFormat.Text));
    }
}

Hi any progress in our issue, has it been analysed? do you have an estimated fix time?
The work around didnt do it for us?
Br Lars

Hi Lars,

Thanks for your inquiry. I have verified the status of your issue
from our issue tracking system and like to share with you that your
issue is under analysis phase at the moment. I have requested the
development team to share the ETA of this issue. As soon as any
information is shared by them, I will be more than happy to share that
with you.

Thanks for your patience.

Hi Lars,

Thanks for your patience. Please use the latest version of Aspose.Words for .NET 15.2.0 and use following code example to achieve your requirements.

Document doc = new Document(MyDir + "test.doc");
string t = doc.ToString(SaveFormat.Text);
StreamWriter outfile = File.CreateText(MyDir + "aw.txt");
outfile.Write(t);
outfile.Close();