Header/Footer error on multiple pages
I have a app which produces a multi page pdf.
on the produced pdf, there is a header and footer. the header is placed in a 2 column table so that there is an image to the left and right, and the footer is in a 3 column table so that there are images in the middle, left and right. when we move to the second page, the tables change a bit and some columns disappear.
i was able to reproduce the problem on playground
please take a look into it.
// playground requires you to assign document definition to a variable called dd
var dd = {
pageSize: 'letter',
pageOrientation: 'portrait',
pageMargins: [40, 55, 40, 60],
header: {
margin: [10, 10],
columns: [
{
table: {
widths: ['50%', '50%'],
body: [
[
{
image: 'sampleImage.jpg',
width: 140, height: 26,
alignment: 'left'
},
{
image: 'sampleImage.jpg',
width: 140, height: 26,
alignment: 'right'
}
]
]
},
layout: 'noBorders'
}
]
},
footer: {
margin: [10, 10],
columns: [
{
table: {
widths: ['33%', '33%', '33%'],
body: [
[
{
image: 'sampleImage.jpg',
width: 140, height: 26,
alignment: 'left'
},
{
image: 'sampleImage.jpg',
width: 140, height: 26,
alignment: 'center'
},
{
image: 'sampleImage.jpg',
width: 140, height: 26,
alignment: 'right'
}
]
]
},
layout: 'noBorders'
}
]
},
content: [
'First page',
'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n',
"second Page"
]
}
Any feedback
same problem here! one center image in header works fine on first page, but is shifted to the far right on the following pages!
Same problem here. Seems to be an issue with margins. At least also the positioning of images having a margin is wrong. Left margins are sumed up on every page, pushing the image more and more to the right.
I was able to get around this by passing a function to the header, as suggested in the doc's header and footer section.
var docDefinition = {
header: function() {
var _left = 285;
return {
margin: [_left, 10],
columns: [
{
// you'll most often use dataURI images on the browser side
// if no width/height/fit is provided, the original size will be used
image: 'data:image/jpeg;base64,...encodedContent...',
width: 300,
alignment: 'center',
}
]
}
},
footer: {...}
}
Hope this helps.
Fixed in version 0.1.22.