-
Notifications
You must be signed in to change notification settings - Fork 354
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
Implement line breaks #159
Comments
I have just added a section about this problem in the new FAQ : http://docxtemplater.readthedocs.org/en/latest/faq.html#how-to-insert-linebreaks It permits you to write {@text|rawHtml} when text is 'line1\nline2' What do you think ? |
@edi9999 I don't really like this solution because it doesn't keep the formatting from the docx. Imagine you have different docx with different formatting and you want to add some text with line breaks... The solution I propose keeps the formatting. |
The problem is that it is not possible to do the transformation : {text} {#multilines}{line} because
are inline elements separated by a block element. I think it would be possible to keep the formatting when inserting linebreaks only if you implement some logic to copy the style from one paragraph to the other. However, I don't wish that to be in docxtemplater core. But I think it would be a great opportunity to create a module : https://github.com/open-xml-templating/docxtemplater#modules |
If the docx was html (which is similar to xml), it would like to be the following:
with
I think that shows you the complexity. |
i tried this http://docxtemplater.readthedocs.io/en/latest/faq.html#how-to-insert-linebreaks it works but the font family changed to times new roman instead of arial. and the text location is changed to the left side instead of on the right side. |
Can you open a new issue for this @araneta ? |
This is now fixed in version 3.8.0 with the option :
|
I know, it's a frequent posted issue and I already found the solutions but I think we should be able to implement it so it becomes transparent to the user. Here is what I do to keep the format and add break lines:
And in my JavaScript code, I break my text as follow:
So my question is, if we can do it like that, would it be possible to use normal variable in the docx {text} and detect line breaks in the JavaScript library and implement it transparently so the user doesn't need to take care of this? The line break is so useful that I really think we should find a way to make it work by default...
What do you think?
The text was updated successfully, but these errors were encountered: