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
Get text including line breaks from uploaded pdf

I am currently working on a small website, on which it should be possible to upload a .pdf file. For the websites functionality, I need to read the text from the pdf into a variable, including the line breaks. So for example if the text in the pdf is:

Hello World
How are you today?

Then the text in the variable should be "Hello World\nHow are you today?".

I have tried several things, but none of these worked for me.

HTML:

<input type="file" id="file" accept=".pdf">

I have tried the following code in my app.js:

function readPdf(){
    const file = document.getElementById('file').files[0];
    const reader = new FileReader();
    var output = "";
    reader.addEventListener("load", function () {
        output += reader.result;
    }, false);

    if (file) {
        reader.readAsBinaryString(file);
    }
    return output;
}

But this is only giving me a hieroglyphic string.

Has anyone ever tried something like this and could tell me the way how it is done?

Thanks in advance

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!