Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line breaks in replacement text #2

Open
thepigeonoftime opened this issue Sep 17, 2020 · 4 comments
Open

Line breaks in replacement text #2

thepigeonoftime opened this issue Sep 17, 2020 · 4 comments

Comments

@thepigeonoftime
Copy link

Hi,
I'm looking for a way to include line breaks in the replacement text (with special placeholders like \n or ${break}).
So far, wherever I perform a sub-replacement to insert "</w:t><w:br/><w:t>" for those break-placeholders, it just gets printed as characters into the document. Any chance to point me to a good place to add something like that (if possible at all)?

@phip1611
Copy link
Owner

Hi @timepigeon
Hm, for me it works to add "\n" into the replaced text.
placeholderMap.put("${NAME}", "Phi\nlipp");

With the .docx-File in src/test/resources the output has a line break. I think this should work for you too, if I understand you right?

Bildschirmfoto 2020-09-17 um 18 03 37

PS: In case you want to use this in your project: I try to add this to Maven central in the next hours.

@thepigeonoftime
Copy link
Author

Hm, for some reason \n gets converted to space for me. I will check this out over the weekend and report back. (I've added the package as a Github dependency in Maven, no rush on publishing it to central from my side. Although it deserves to be on there.)

@phip1611
Copy link
Owner

Okay I have an update on this. \n works when I view the docx document in Pages on my Macbook. Neither \n nor \r\n works when I view the document in Microsoft Word. @timepigeon

@phip1611 phip1611 reopened this Nov 23, 2022
@kadtaras
Copy link

kadtaras commented Mar 1, 2023

I have the same problem. When I open my generated .docx file in Pages, it shows okay, but it \n doesn't work in Microsoft Word

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants