One line added after each merge field of html

Hello there,

I’m facing a situation that as merging with html content it’s always added one extra line after each html merge field. Is it a way NOT to do that?
Sample output:
image.png (29.5 KB)

Sample code, actual output and expected output: line-added-after-each-html-field.zip (37.9 KB)

Thanks

@stco

Please use the following modified code to get the desired output. Hope this helps you.

public void fieldMerging(FieldMergingArgs e) throws Exception {
    System.out.println("process: " + e.getFieldName());
    if (mBuilder == null)
        mBuilder = new DocumentBuilder(e.getDocument());

    if (e.getFieldName().startsWith("html:")) {
    	Cell cell = (Cell)e.getField().getStart().getAncestor(NodeType.CELL);
    	mBuilder.moveToMergeField(e.getFieldName());
        mBuilder.insertHtml((String) e.getFieldValue());
        
        if(cell != null)
        {
        	if(cell.getLastParagraph().toString(SaveFormat.TEXT).trim().length() == 0)
        		cell.getLastParagraph().remove();
        }
    }
}