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

218
Visualizações
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
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