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

351
Views
Docxtemplater lee un archivo de Word con salto de línea

Tengo un archivo de Word, que necesito leer, pero al usar doc.getFullText() las líneas nuevas no se leen.

¿Como lo puedo hacer?

 <script src="https://cdnjs.cloudflare.com/ajax/libs/docxtemplater/3.8.0/docxtemplater.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/2.6.1/jszip.js"></script>
 const reader = new FileReader(); reader.onload = async (e) => { const text = e.target.result; const zip = new JSZip(text); const doc = new window.docxtemplater().loadZip(zip).setOptions({ linebreaks:true }); const t = doc.getFullText(); console.log(t) }; reader.readAsBinaryString(files[0]);

Docx:

 1 00:00:01.392 --> 00:00:03,734 [Speciale Natale uomo che corre] 2 00:00:05,611 --> 00:00:08.098 <i>[L'incubo di Natale] Sottotitoli di DramaFever</i> 3 00:00:10,586 --> 00:00:14,909 [Un giorno piovoso di dicembre...] 4 00:00:17,251 --> 00:00:18,776 Cosa stai facendo qui? 5 00:00:20,035 --> 00:00:21,529 Cosa stai facendo davanti di casa mia?
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prueba este código:

 const doc = new Docxtemplater(zip, {linebreaks: true});

si desea renderizar en html, reemplace \n a <br>

O

Puedes probar con esta biblioteca cualquier texto

about 4 years ago · Juan Pablo Isaza Report
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!