#StackBounty: #java #android #apache-poi #docx Getting the lines of each paragraphs of a docx with Apache-POI

Bounty: 300

I am using the library Apache-POI for my app. Specifically, POIshadow-all (ver. 3.17) for reading a Word document.
I am successfully extracting every paragraph as follows:

enter image description here

what I actually need is extract every line, as follows:

enter image description here

The code to extract every paragraph is this:

 try {

            val fis = FileInputStream(path.path + "/" + document)
            val xdoc = XWPFDocument(OPCPackage.open(fis))

            val paragraphList: MutableList<XWPFParagraph> = xdoc.paragraphs

            private val newParagraph = paragraph.createRun()


            for (par in paragraphList) {

                    var currentParagraph = par.text
                    Log.i("TAG","current: $currentParagraph")


The variable currentParagraph returns a whole paragraph, as expected. However, I would need a variable named currentLine which returns a single line.

I’ve research about this issue in stackoverflow and other sites. I’ve found some proposals but none of them works for me.
I also tried get dates by ctr and using XWPFRun, without any success.

I would be grateful for any recommendation on how to proceed.

Thanks in advance for your help.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.