Skip to content

feat: support new table properties in PDF export #1475

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

Merged
merged 5 commits into from
Mar 4, 2025
Merged

Conversation

nperez0111
Copy link
Contributor

This adds support for table cell text & background color, alignment, and header cells to the PDF export of tables.

One thing this does not support at the moment is rowspan & colspan tables, with the current approach it looks like it would take a good amount of work to get this to export properly

Copy link

vercel bot commented Mar 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Mar 4, 2025 1:37pm
blocknote-website ✅ Ready (Inspect) Visit Preview Mar 4, 2025 1:37pm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

table headers are not supported atm because they require modifying the run of the paragraph to make the cell's content bold.

Table paragraph color seems to not be working at the moment either, maybe to do with the inheritance of paragraph within a paragraph's color?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rowspan & colspan change up how this layouting would work, I think we'd need to rewrite this completely to allow them to be supported

Copy link
Collaborator

Choose a reason for hiding this comment

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

pdfkit just merged this last week: foliojs/pdfkit#1577 which hopefully should solve a lot of edge cases related to tables.

I'm checking with the author of react-pdf: diegomura/react-pdf#3110

cell.props.textAlignment
);
})(),
run:
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • you could add "bold" here as well for headers

My guess why it's not working might be because the children of the paragraph overwrite all the styles. You could break / log here to confirm:

If that's not the case, then maybe the styles don't inherit the nested runs and we'd need to find another way.

lmk if you need help with digging in further

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, when I looked into it, I think it is because the children overwrite the styles. So would need to somehow spread that change to the children (like implementing a sort of inheritance).

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.

2 participants