snowindy/scriptlet4docx

Line Break Characters aren't working correctly

Closed this issue · 7 comments

Perhaps I'm doing something incorrectly, but looking at DocxTemplater.java and this line:

sv = sv.replace("\n", "<w:br/>");

It appears that new line characters (\r\n or \n) should result in <w:br/> elements being replaced within the XML. What I'm seeing instead is the <w:br/> text within the document post processing.

Expected:

Tyler Carver
Steven White
Amanda Bryant
Brenda Wout

Actual:

Tyler Carver<w:br/>Steven White<w:br/>Amanda Bryant<w:br/>Brenda Wout

Could you share the document with this sample?

Sure, I'm fairly swamped at work right now, but will this week.

scriptlet4docx-linebreaks-input.docx

Test Case:

import org.scriptlet4docx.docx.DocxTemplater

DocxTemplater docxTemplater = new DocxTemplater(new File("<path>/scriptlet4docx-linebreaks-input.docx"));

def params = [
	data: [
    	"line1",
        "line2",
        "line3"
    ].join("\n")
]

docxTemplater.process(new File("<path>/scriptlet4docx-linebreaks-output.docx"), params)

Fixed in 0.8.5. Should arrive in maven central soon

scriptlet4docx-linebreaks-input.docx

I'm using version 0.8.5, but in my case this case does not work, maybe I'm doing something wrong?

@Laiserg1k Okay I will check

Working right in 0.8.6, tested with your test case