pdfmake
pdfmake copied to clipboard
Margins of nodes with relativePosition or absolutePosition affect the normal flow of the layout
Width and height of nodes with relativePosition or absolutePosition do not affect the normal flow of the layout, they float in their own independent layout without occupying any space. But its margins they do affect the normal flow of the layout. For example this doc definition:
var dd = {
content: [
{ text: 'Text with relative position', relativePosition: {x: 90, y: 0 }},
{ text: 'Regular text 1'},
{ text: 'Following the regular flow "Regular text 2" should appear here', color: 'grey'},
{ text: 'Text with relative position and margins', margin: [0, 50, 0, 0], relativePosition: {x: 150, y: 0 }},
{ text: 'Regular text 2'},
]
};
Has this outcome:
Regular text 2
should appear just below Regular text 1
but the margins of the relative positioned text is affecting its position.
With absolute positioning is even more noticeable:
var dd = {
content: [
{ text: 'Text with relative position', relativePosition: {x: 90, y: 0 }},
{ text: 'Regular text 1'},
{ text: 'Following the regular flow "Regular text 2" should appear here', color: 'grey'},
{ text: 'Text with absolute position and margins', margin: [0, 50, 0, 0], absolutePosition: {x: 150, y: 0 }},
{ text: 'Regular text 2'},
]
};
Has this outcome:
Regular text 2
is being affected by the margins of the node with absolute position when the node itself is not being affected by its margins because its 'x' and 'y' have priority.
So I think this can be considered a bug and it would be a good idea to completely ignore the margins of nodes with relativePositon or absolutePosition and just position them with their 'x' and 'y'. This way the regular layout flow would be free of interference.