Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/table cell vertical alignment #2436

Open
wants to merge 38 commits into
base: master
Choose a base branch
from

Conversation

Kran67
Copy link

@Kran67 Kran67 commented May 17, 2022

Table cell vertical alignment - for stack, column, list, text, image, qr, svg

@Kran67
Copy link
Author

Kran67 commented May 17, 2022

Hi,
You can use table cell vertical alignment with one new property 'verticalAlign' (values: 'middle', 'bottom', see example)

@jbenjoy2
Copy link

jbenjoy2 commented Jun 1, 2022

@Gheeks @bpampuch if we could get this feature merged and released asap that would be lovely! Thank you

@jbenjoy2
Copy link

jbenjoy2 commented Jun 6, 2022

@Gheeks @bpampuch if we could get this feature merged and released asap that would be lovely! Thank you

@bpampuch definitely need to get this feature released asap so if we could please get this merged and released, we'd all really appreciate it.

@SawkaDev
Copy link

SawkaDev commented Jun 7, 2022

Agreed. Eager for this feature. Thanks for your work!

@maxpropp
Copy link

Can't wait for this to be merged

Copy link

@dumbasPL dumbasPL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need all the begin/end - Vertical alignment comments everywhere? Git already shows a nice diff.
Alos why do we need the __ prefix everywhere? Rest of this project seems to use "normal" names.

// begin - Vertical alignment
const lastNode = this.__nodesHierarchy.pop();
lastNode.__contentHeight = Math.max(...columns.map(c => c.__contentHeight));
this.__nodesHierarchy[this.__nodesHierarchy.length - 1].__contentHeight += lastNode.__contentHeight;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a missing check for this.__nodesHierarchy.length > 0

@@ -613,6 +648,10 @@ class LayoutBuilder {
this.writer.removeListener('lineAdded', addMarkerToFirstLeaf);

this.writer.context().addMargin(-gapSize.width);
// begin - Vertical alignment
const lastNode = this.__nodesHierarchy.pop();
this.__nodesHierarchy[this.__nodesHierarchy.length - 1].__contentHeight += lastNode.__contentHeight;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another missing check for this.__nodesHierarchy.length > 0

cellHeight = table.__rowsHeight[rowIndex].height;
}
if (cellHeight) {
const pageItems = writer._context.pages.flatMap(x => x.items);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for people porting this to the 0.2 branch: This line needs to be

const pageItems = writer.writer.context.pages.flatMap(x => x.items);

dumbasPL added a commit to Createch-Corp/pdfmake that referenced this pull request Jun 10, 2022
@Kran67
Copy link
Author

Kran67 commented Jun 10, 2022

why do we need all the begin/end - Vertical alignment comments everywhere? Git already shows a nice diff. Alos why do we need the __ prefix everywhere? Rest of this project seems to use "normal" names.

begin/end - Vertical alignment> only for information
Prefix __ is only to avoid future naming conflicts

@maxpropp
Copy link

are there news regarding this?

@SawkaDev
Copy link

Any estimate on when this can be merged? I think this feature will greatly improve pdfmake tables!

@fe-art
Copy link

fe-art commented Aug 31, 2022

Guys please, we've been asking for this feature since 2014 ❤️

@DanielOfCourse
Copy link

It would be so awesome to have this merged in, plsplspls

@maxpropp
Copy link

Is there a problem with this PR? So we can update it and finally merge it?

@ChrisSimoniMBT
Copy link

@Kran67 have you addressed the changes so this can get merged?

Copy link

@ChrisSimoniMBT ChrisSimoniMBT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added what I believe are the suggested changes so we can rebase inside github if desired.

// begin - Vertical alignment
const lastNode = this.__nodesHierarchy.pop();
lastNode.__contentHeight = Math.max(...columns.map(c => c.__contentHeight));
this.__nodesHierarchy[this.__nodesHierarchy.length - 1].__contentHeight += lastNode.__contentHeight;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.__nodesHierarchy[this.__nodesHierarchy.length - 1].__contentHeight += lastNode.__contentHeight;
this.__nodesHierarchy.length > 0 && (this.__nodesHierarchy[this.__nodesHierarchy.length - 1].__contentHeight += lastNode.__contentHeight);

Suggested check

@@ -613,6 +648,10 @@ class LayoutBuilder {
this.writer.removeListener('lineAdded', addMarkerToFirstLeaf);

this.writer.context().addMargin(-gapSize.width);
// begin - Vertical alignment
const lastNode = this.__nodesHierarchy.pop();
this.__nodesHierarchy[this.__nodesHierarchy.length - 1].__contentHeight += lastNode.__contentHeight;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.__nodesHierarchy[this.__nodesHierarchy.length - 1].__contentHeight += lastNode.__contentHeight;
this.__nodesHierarchy.length > 0 && (this.__nodesHierarchy[this.__nodesHierarchy.length - 1].__contentHeight += lastNode.__contentHeight);

Suggested check

@ChrisSimoniMBT
Copy link

@bpampuch @liborm85 Any input on this PR?

@nw-onediscovery
Copy link

Would love to see this feature merged soon.

@anthonygacis
Copy link

update pls.

@manuelncfa
Copy link

I'm in need of this feature, could this be merged and released?

@jdwit
Copy link

jdwit commented Feb 9, 2024

Would be great if this is merged 👍

@KostyanWest
Copy link

I prefer to install this library from the SirFull's fork rather than wait for this PR to be merged. Fortunately, package managers such as npm can do it directly from github from the specific branch:
npm install SirFull/pdfmake#table_cell_vertical_alignment
or from the specific commit:
npm install SirFull/pdfmake#aec02a68af06c44991ae3dc45bdf443dde570ba4
I'm not sure any update will be as important as this one.

@chjiyun
Copy link

chjiyun commented Jun 2, 2024

unable to install

I prefer to install this library from the SirFull's fork rather than wait for this PR to be merged. Fortunately, package managers such as npm can do it directly from github from the specific branch: npm install SirFull/pdfmake#table_cell_vertical_alignment or from the specific commit: npm install SirFull/pdfmake#aec02a68af06c44991ae3dc45bdf443dde570ba4 I'm not sure any update will be as important as this one.

@KostyanWest
Copy link

unable to install

I prefer to install this library from the SirFull's fork rather than wait for this PR to be merged. Fortunately, package managers such as npm can do it directly from github from the specific branch: npm install SirFull/pdfmake#table_cell_vertical_alignment or from the specific commit: npm install SirFull/pdfmake#aec02a68af06c44991ae3dc45bdf443dde570ba4 I'm not sure any update will be as important as this one.

Sorry, I'm new to the web development and the stuff around it, so I have no idea where the problem is. I installed this library form the specific commit right now (2nd example) and everything seems to be okay. This line
"@sirfull/pdfmake": "github:SirFull/pdfmake#aec02a68af06c44991ae3dc45bdf443dde570ba4",
has also been added to the package.json.

@t0m-4
Copy link

t0m-4 commented Sep 7, 2024

Hello, @Kran67 and me are working together, last week i will try to merge last version and ill add recommended suggestions from here.

@t0m-4
Copy link

t0m-4 commented Sep 9, 2024

I updated the fork with the latest updates and suggestions.

I also added a way to stretch the table height according to the parent. To do this, you need to set a line height to "*", the generation will then be done twice to know the available height of the parent and modify the line height accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.