Get Paragraph Count in Word Document using C# | Find Total Number of Paragraphs in DOCX File

Hi,support,
Here I report a bug for words.dll:

For the sample doc file, the true paragraph count is about 12, whereas the words.dll get the paragraph count is about 3132770.
Please refer to the sample file for your checking and fixing it. And you must change the fileextension ‘zip’ as ‘doc’.
Sample.zip (1.5 MB)

Thanks!

Ducaisoft

@ducaisoft,

As shown in this screenshot.zip (174.9 KB), MS Word 2019 reports that there are 0 Paragraphs and 12 Lines in this Word document. Can you please also provide piece of Aspose.Words’ source code that you are using on your end to get the Paragraph count?

Dim ParaN As Integer = doc.GetChildNodes(NodeType.Paragraph, True).Count
sometimes, ParaN is 0, sometimes, ParaN is 2,sometimes ParaN is about 3132770.

@ducaisoft,

The latest version of Aspose.Words for .NET i.e. 20.3 returns 2 when executing your code against the Sample.doc you shared earlier. Essentially, there are two paragraphs in this Word document. Please open it with MS Word, then press Ctrl+F and enter ^p in search text box. This will help to find those two paragraphs. So, this seems to be an expected behavior. Please also see the following screenshot: