Home > Back-end >  Export two images side by side on header pdf
Export two images side by side on header pdf

Time:01-04

I have been using enter image description here

Regards

CodePudding user response:

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

  •  Tags:  
  • Related