How to: Cariage return in docx?



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

    0_1615362970264_upload-b6e90863-df3a-4a4d-8d0c-1cc940804b8f

    And like:

    0_1615363118640_upload-bd768ec2-a344-43c5-9a36-224644126dc5

    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
    https://github.com/jsreport/jsreport/issues/713



  • 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:

    0_1615367895287_upload-861d6d3e-80af-4e34-b6aa-ec72e1048343

    Template looks like this:

    0_1615367941334_upload-abf67b11-a34e-4beb-97ee-ba021557a8fb

    Function looks like this:

    0_1615367973404_upload-c482cddc-9b5d-4a0e-a1a3-8131bdaeebf9



  • @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
    http://localhost:5488/studio/templates/cmc5B9R6-g


Log in to reply
 

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