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

205
Visualizações
Export two images side by side on header pdf

I have been using this plugin for data table and exporting Excel and PDF files. My problem comes with PDF file export, I want to add two images on header page side by side but the only result that I got is an image in a row and the other on the next line, this is part of my code:

                 customize: function (doc) {
                    
                    if (doc) {
                        doc.content.splice(0, 0, [{
                            margin: [0, 0, 0, 0],
                            alignment: 'left',
                            image: 'base64_Image',
                            width: 100,
                            height: 40,
                        },{
                            margin: [0, 0, 0, 0],
                            alignment: 'right',
                            image: 'base64_Image',
                            width: 100,
                            height: 40,
                        }]);

                        console.log(doc);
                    }
                }

and this is the result:

enter image description here

Regards

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To add an image to the header as you want, I suggest you do the following:

  • Add pageMargins attribute to doc
  • Use the header attribute of doc to add an image.

2 images side by side

customize: function (doc) {
    doc.pageMargins = [40, 80, 40, 60]
    doc.header = [
        {
            margin: 10,
            columns: [
                {
                    image: 'base64_Image',
                    width: 100,
                    height: 40,
                    padding: 10
                },
                {
                    image: 'base64_Image',
                    width: 100,
                    height: 40,
                }
            ],
            columnGap: 10 // optional space between columns
        },
    ]
    return doc
}

If you want an image on the left and an image on the right of the header, you just need to add adjust value of columns attribute in header. Try like this:

customize: function (doc) {
    ...
    doc.header = [
        {
            ...
            columns: [
                {
                    image: imageBase64,
                    width: 100,
                    height: 40,
                    padding: 10
                },
                {
                    width: '*',
                    text: ''
                },
                {
                    image: imageBase64,
                    width: 100,
                    height: 40,
                }
            ],
        },
    ]
}

Sample code here

about 4 years ago · Juan Pablo Isaza Relatório
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