Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda