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

stopOpacity prop in <Stop /> component causes rendering failure #3003

Open
EvHaus opened this issue Dec 19, 2024 · 0 comments
Open

stopOpacity prop in <Stop /> component causes rendering failure #3003

EvHaus opened this issue Dec 19, 2024 · 0 comments

Comments

@EvHaus
Copy link

EvHaus commented Dec 19, 2024

Describe the bug

When specifying a stopOpacity of anything other than 1, gradients will not render in react-pdf.

To Reproduce

const Test = () => (
  <Document>
    <Page>
      <Svg>
        <Defs>
          <LinearGradient id="grad">
            <Stop offset="0%" stopColor="green" stopOpacity="0" />
            <Stop offset="100%" stopColor="red" stopOpacity="1" />
          </LinearGradient>
        </Defs>
        <Circle fill="url(#grad)" cx="100" cy="100" r="100"/>
    </Svg>
    </Page>
  </Document>
);

ReactPDF.render(<Test />);

https://react-pdf.org/repl?code=3187b0760ce02e00402a05368c0bc30050129503e0c0a061801e0044460057016c130a1d0a24801404301cc1479e78819401b871ebcfa90400cc228b17c00c804b3008d802700e26ad801345756229d28011076d3a4ecb97df9410001c60849d21145300180290998d11c018440006c40d54dcc10e8fc021c01e41cd98114a0013d4c0118fc01e9ac6c48ed1d9d5c21dcb33c7d63ec1d82c2224cd4112dfc6b139352324db260f2980b88729455d4b575f5e9f2f87225a4a689890314d580421061251442434d28d443d00189cd7530fd80003c2b3dcebb332afc1bee6efb79068445fa4873d8b94507c8545a24df09800373e1f0002555300a02c52000c400744d300e8106a7431110c83cb83f04000

If you change stopOpacity from 0 to 1 in the code above, the circle will render.

Expected behavior

A circle with a gradient should render where the left-side fades into transparency.

Screenshots

Kapture 2024-12-18 at 22 15 34

Desktop:

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

No branches or pull requests

1 participant