Skip to content

Commit

Permalink
backport PR #2776
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Sep 4, 2024
1 parent 8d8f5d9 commit c6d5d51
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 15 additions & 4 deletions src/elementWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,21 @@ ElementWriter.prototype.addFragment = function (block, useBlockXOffset, useBlock
var v = pack(item.item);

offsetVector(v, useBlockXOffset ? (block.xOffset || 0) : ctx.x, useBlockYOffset ? (block.yOffset || 0) : ctx.y);
page.items.push({
type: 'vector',
item: v
});
if (v._isFillColorFromUnbreakable) {
// If the item is a fillColor from an unbreakable block
// We have to add it at the beginning of the items body array of the page
delete v._isFillColorFromUnbreakable;
const endOfBackgroundItemsIndex = ctx.backgroundLength[ctx.page];
page.items.splice(endOfBackgroundItemsIndex, 0, {
type: 'vector',
item: v
});
} else {
page.items.push({
type: 'vector',
item: v
});
}
break;

case 'image':
Expand Down
4 changes: 3 additions & 1 deletion src/tableProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,9 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
h: bgHeight,
lineWidth: 0,
color: fillColor,
fillOpacity: fillOpacity
fillOpacity: fillOpacity,
// mark if we are in an unbreakable block
_isFillColorFromUnbreakable: !!writer.transactionLevel
}, false, true, writer.context().backgroundLength[writer.context().page]);
}

Expand Down

0 comments on commit c6d5d51

Please sign in to comment.