Remove numbering from certain paragraph

Hi,

I am updating a document by replacing some special words with multiple headings and corresponding descriptions. I am adding the heading using builder.writeln() method and uses heading-1 style (To capture in the TOC) and description in normal style. In some cases, the updated document heading -1 style will have a number so that the heading will come with numbering. In some cases, the customer will add one heading which may have multiple lines (will add enter).In this case, the list item adds numbering to all the paragraphs (one heading will have multiple numbering, which I don’t want. So is there any way I can remove the numbering after enter with the builder?

Thank you

@Gptrnt To achieve what you need you should use soft line break instead of paragraph break. For example see the following code:

String data = "First Line\nSecond Line\rThird Line\r\nFourth Line";

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.getListFormat().applyNumberDefault();
// There will be 4 paragraphs
builder.writeln(data);
// Replace line breaks with soft line breaks.
builder.write(data
    .replace(ControlChar.CR_LF, ControlChar.LINE_BREAK)
    .replace(ControlChar.PARAGRAPH_BREAK, ControlChar.LINE_BREAK)
    .replace(ControlChar.LINE_FEED, ControlChar.LINE_BREAK));

doc.save("C:\\Temp\\out.docx");