react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

toBlob throws an error with react-pdf elements (Svg, Defs)

Open Scott-Kinzer opened this issue 1 year ago • 2 comments

Describe the bug toBlob throws an error with some react-pdf elements (Svg, Defs)
Error: renderFn is not a function

To Reproduce Next.js, react-pdf version: 3.3.8

With Defs, toBlob throws an error, but if I delete it and add a standard fill color to the circle, it works correctly.

  <G>
    <Defs>
        <LinearGradient id="myLinearGradient">
          <Stop offset="5%" stopColor="gold" />
          <Stop offset="95%" stopColor="red" />
        </LinearGradient>
      </Defs>
    <Circle cx="5" cy="5" r="4" fill="url(‘#myLinearGradient’)" />
  </G>

Scott-Kinzer avatar Feb 15 '24 20:02 Scott-Kinzer

I have the same problem😭😭😭 < Defs> Without Tegg, no problem will arise.

Tommy052 avatar Jun 18 '24 04:06 Tommy052

It looks like In reaact-pdf Defs is only supported as a child of Svg

This PR https://github.com/diegomura/react-pdf/pull/2836 will at least write to the console the original problem instead of throwing the error: "Error: renderFn is not a function"

obi-awyss avatar Aug 02 '24 14:08 obi-awyss