Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
How to read docx with line breaks in website js?

I am currently working on a web app for which I need to read text from a .docx-file in the front-end, using JavaScript. For the later usage of the text it's important to also read linebreaks in the text. Currently I am working with docxtemplater's getFullText()-method, which is fine to read the text, but it does not give me the line breaks.

My current code lokes as follows:

function openDocx(event) {
    var input = event.target;
    var reader = new FileReader();
    reader.onload = function () {
        var zip = new JSZip(reader.result);
        var doc = new window.docxtemplater().loadZip(zip);
        var text = doc.getFullText();
        console.log(text)
    };
    reader.readAsBinaryString(input.files[0]);
};

So for the text in a .docx, let's say

Hello World
How are you?

It would give me "Hello WorldHow are you?", but I would want "Hello World\nHow are you?". Has anybody else had the same problem and found a solution or does anybody have an idea how to get the line breaks? If necessarry, I am also willing to go away from docxtemplater and use another library.

Thanks in advance

Robert

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!