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

224
Views
Cómo almacenar y recuperar los datos de la función javascript

Soy nuevo en javascript y quiero almacenar los datos de la función. Esta es la función que he escrito.

 function OnlyReadOneText(txt){ var file = event.target.files[0]; var api = new FileReader(); api.onload = function(){ var typedarray = new Uint8Array(this.result) const task = pdfjsLib.getDocument(typedarray) task.promise.then((pdf) =>{ console.log("This pdf has " + pdf.numPages + " pages") var countPromises = []; for (var j = 1; j <= pdf.numPages; j++) { var page = pdf.getPage(j); var txt = ""; countPromises.push(page.then(function(page) { // add page promise var textContent = page.getTextContent(); console.log(textContent ); return textContent.then(function(text){ // return content promise return text.items.map(function (s) { return s.str; }).join(''); // value page text }); })); } // Wait for all pages and join text return Promise.all(countPromises).then(function (texts) { txt = texts.join(''); //<---------------- I want this piece of info return texts.join(''); }); }); } api.readAsArrayBuffer(file); }

Lo hago de esta manera en javascript:

 var ans = OnlyReadOneText();

Solo devuelve nada sin "respuesta". ¿Cómo obtener texts.join y mostrarse en ans?

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!