How to: Cariage return in docx?

  • I'm looking for a way to handle new lines in docx. I have tried several things like:


    And like:


    I tried both {{foo}} and {{{foo}}} but didn't get the expected result. What's the right way to handle new lines? Or isn't it implemented yet?

  • Please check this issue for the solution

  • Thanx for the quick reply! Works like a charm. In answer to your question in issue 713. In my opinion we should make it work out of the box like the simple HTML. Being able to format text in an easy way is essential to this powerful tool! Thank you for developing.

    My data now looks like this:


    Template looks like this:


    Function looks like this:


  • @jan_blaha Solution worked fine for simple solution but unfortunately not for bigger data files. I get the error when using the ui:

    Error: . file is too big and it pass the upload limits of server. Request failed with status code 413
    at createError (C:\Data\jsreportapp\node_modules\axios\lib\core\createError.js:16:15)
    at settle (C:\Data\jsreportapp\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (C:\Data\jsreportapp\node_modules\axios\lib\adapters\http.js:236:11)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

    When using the api a docx is generated but it's corrupted.

    Is there a solution to work around this issue.

  • Error: . file is too big and it pass the upload limits of server. Request failed with status code 413

    This is thrown by the server that is doing the preview. It can't handle the bigger files.
    In this case, you need to use the download button from the "Run" context menu.

    If the docx is corrupted, it isn't likely because of the size. You will need to try to isolate the particular thing that corrupts the docx. If you are lucky, we will gladly check it out and try to fix it.

  • Drilled it down to the "\n" but wasn't able to fix it. Made a work around by replacing de cariage returns in my pre processing script into <w:br/> and using {{{foo}}}. It works except if you put a formating function around like {{#docxStyle textColor=(getMarkColor text)}}{{{text}}}{{/docxStyle}}.

  • No, unfortunately the work around is unstable.

  • Could you please elaborate on what doesn't work for you?
    It seems to work for me also with style around

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.