Add Border to Paragraph in Word Using POI

We have already see the creation of Word file and adding Paragraph to it using Apache POI. Now we will see how to add Border to Paragraph in Word using POI.

Classes / Interfaces Used


org.apache.poi.xwpf.usermodel.XWPFDocument is used to create the MS Word Docs in the .docx formats.


org.apache.poi.xwpf.usermodel.XWPFParagraph is used to create a paragraph in the word file.


org.apache.poi.xwpf.usermodel.XWPFRun is used to add/change the text in a specified element/region.

The Code


When we run the above code we get the message on the console and a word document with text and border around it is created at the location we had specified.

Add Border to Paragraph in Word Using POI