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

145
Visualizações
Merging two or more PDFs (blobs)

I have a webpage that contains a table of reports. When you click on any of the reports individually, it downloads and displays it as a PDF in a new tab.

My current task, and the problem that I'm having, is that I also need to be able to download all of the reports in that table and display in a new tab as one, multipage PDF.

Where I have it now, it seems like I'm getting two PDFs worth of data (judging by the size I can see in the console). However when the PDF opens in a new tab, it's only one page. Not two like I'm hoping for. The PDF does not get corrupted in the process, it seems to only display the first PDF.

Here is my downloadAll function:

async downloadAll() {
    var parts = [] // parts array to store blob 'parts' to later be combine
    var cals = this.state.calibrations // the array of JSONs that include the blob UUID
    let count = 0
    await new Promise((resolve) => {
        cals.forEach(async (cal) => {
            try {
                let blob = await (await fetch(api_url + this.state.user.company + '/blobs/' + cal.blob_id + '/download', { headers: { Authorization: this.state.auth_token }})).blob() // API call to download blob with the UUID (cal.blob_id)
                parts.push(blob) // push the resulting blob to the parts array
            } catch (e) {
                console.log(e)
            } finally {
                count += 1
                if(count === cals.length) {
                    resolve()
                }
            }
        })
    })
    var blobBuilder = new Blob(parts, { type: 'application/pdf'}) // create a new blob of type PDF with our now-filled parts array
    console.log(blobBuilder)
    window.open(URL.createObjectURL(blobBuilder), '_blank'); // open blobBuilder PDF in a new tab
}

Something tells me that it's not as simple as smashing two pdfs together (obviously, I wouldn't be asking if it was that simple) but I'm not sure how to manipulate the data in the PDF itself.

Thank you for reading and please let me know if you need more information.

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