Remove style identifier border from content


we have a template feature where we replace some tokens with values from the database in our application. Some values are plain strings and some are HTML. We pick the format of the token and apply it to the values while replacing tokens. While the plain string values are replaced properly and take the font type and size applied from the token format, but, if the template heading_1 style has border property it getting applied to the plain text. We need help in remove this unwanted border applied to the plain text.

Please find the sample, code, input and output attached for your reference TokenstyleIssue (5).zip (80.1 KB)



The template document has heading style with border. You can remove the border of style using following code snippet. Hope this helps you.

Document doc = new Document(MyDir + "template.docx");
doc.getStyles().getByStyleIdentifier(StyleIdentifier.HEADING_1).getParagraphFormat().getBorders().clearFormatting(); + "20.9.docx");