diegomura / diegomura/react-pdf

Upgrading from @react-pdf/renderer 4.1.2 to 4.1.3 causes a variety of issues with `lineHeight` styles

Open
#2,988 11 comments 14 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
5h 6m
Merged PRs (30d)
52

Description

**Describe the bug**

Very similar to #2369, I'm seeing issues with `@react-pdf/renderer` version 4.1.3 where adding a lineHeight style to the page causes all sorts of problems. Possibly caused by [this commit](https://github.com/diegomura/react-pdf/commit/425f1183bba9a83fd5712a1371abb6cea2ed8fca) or maybe [this one](https://github.com/diegomura/react-pdf/commit/2c3c887ea2d3aed2863f49bff375d08feaf975aa)?

The issue also exists in the latest 4.1.6 version.

**To Reproduce**

For example, if you add a `lineHeight`, any content rended via the `render={() => 'foobar'}` prop, won't render anymore. See REPL: https://react-pdf.org/repl?code=3187b0760ce02e00408a057025803c450298c0bc300500943807cf805030c00f0022230080b6198531165d400a02180e659a004f003619b006f09229180c00243123e002ca002e18011801d005600be07da74e5400a8614b00138b0026186e4c22460022792003bbda1ee0c6001e84ccc83780542a882e8199959d80801b8c8c80094307980a0b86800c474ecc11c6cf0a91151d0b04392c8800 (Removing the `lineHeight` style makes the text re-appear)

Additionally, a `lineHeight` value of 1.5 in 4.1.2 is half the size that it is in 4.1.3.

![Screenshot 2024-11-29 at 9 22 40 PM](https://github.com/user-attachments/assets/750fa75b-2c29-4e1c-98ec-2854a7cdfb4a)

After some debugging, looks like rolling back `@react-pdf/renderer` to 4.1.2 isn't enough. I need to rollback to the following dependencies to make the problems go away:

- @react-pdf/renderer: 4.1.2
- @react-pdf/layout: 4.1.1
- @react-pdf/reconciler: 1.1.1
- @react-pdf/render: 4.0.1
- @react-pdf/stylesheet: 5.0.1
- @react-pdf/textkit: 5.0.0

I tried to figure out which specific package causes the issues, but it seems like it's a combo of several of them.

**Expected behavior**

A document with a `lineHeight` of 1.5 should have the same rendering between 4.1.2 and 4.1.3.

**Screenshots**

See above.

**Desktop:**

- OS: MacOS
- Browser: Rendering via Bun (server-side)
- React-pdf version: 4.1.3

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.