From d3956e27e5cc3a6d5c3cd923feb59c5c3128a2a4 Mon Sep 17 00:00:00 2001 From: linusbrolin Date: Mon, 25 Sep 2023 21:14:46 +0200 Subject: [PATCH] added support for valign: "bottom" --- index.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6344638..7c23cba 100644 --- a/index.js +++ b/index.js @@ -752,8 +752,14 @@ class PDFDocumentWithTables extends PDFDocument { width: width - (cellPadding.left + cellPadding.right), align: align, }); - // line height, spacing hehight, cell and text diference - topTextToAlignVertically = rowDistance - columnSpacing + (rectCell.height - heightText) / 2; + if(valign === 'bottom'){ + // line height, spacing hehight, cell and text diference + topTextToAlignVertically = rowDistance - (columnSpacing * 2) + (rectCell.height - heightText); + } + else { + // line height, spacing hehight, cell and text diference + topTextToAlignVertically = rowDistance - columnSpacing + (rectCell.height - heightText) / 2; + } } // ------------------------------------------------------------------------------ @@ -866,8 +872,14 @@ class PDFDocumentWithTables extends PDFDocument { width: columnSizes[index] - (cellPadding.left + cellPadding.right), align: align, }); - // line height, spacing hehight, cell and text diference - topTextToAlignVertically = rowDistance - columnSpacing + (rectCell.height - heightText) / 2; + if(valign === 'bottom'){ + // line height, spacing hehight, cell and text diference + topTextToAlignVertically = rowDistance - (columnSpacing * 2) + (rectCell.height - heightText); + } + else { + // line height, spacing hehight, cell and text diference + topTextToAlignVertically = rowDistance - columnSpacing + (rectCell.height - heightText) / 2; + } } // ------------------------------------------------------------------------------