Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda