bpampuch / pdfmake

Client/server side PDF printing in pure JavaScript
http://pdfmake.org
Other
11.66k stars 2.04k forks source link

Canvas does not work in header/footer #1078

Closed crunchtime-ali closed 7 years ago

crunchtime-ali commented 7 years ago

I have been trying to insert a canvas in a header and footer for the last two hours but it is just ignored. There is no error. It is just never rendered.

Here is a minimal example that illustrates my problem in the playground:

var dd = {
    header: function() {
        return [
            {
                table: {
                    widths: [ '*'],
                    body: [[ 
                        {
                            border: [false, false, false, false],
                            fillColor: '#eeeeee',
                            text: '-'

                        },
                    ]]
                },
            },
            { canvas: [ { type: 'rect', x: 170, y: 32, w: 170, h: 40 } ] }

        ]
    },
    content: [
        {text: 'Optional border', fontSize: 14, bold: true, margin: [0, 0, 0, 8]},
        'Text',
    ]
}
liborm85 commented 7 years ago

You have canvas outside the header area.

For example this works:

var dd = {
    header: function() {
        return [
            {
                table: {
                    widths: [ '*'],
                    body: [[ 
                        {
                            border: [false, false, false, false],
                            fillColor: '#eeeeee',
                            text: '-'

                        },
                    ]]
                },
            },
            { canvas: [ { type: 'rect', x: 170, y: 0, w: 170, h: 10 } ] }

        ]
    },
    content: [
        {text: 'Optional border', fontSize: 14, bold: true, margin: [0, 0, 0, 8]},
        'Text',
    ]
}