diff --git a/README.md b/README.md index 2653cc5..58820f2 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ## The problem -One of the best ways to generate PDFs is using [`react-pdf`](https://react-pdf.org/). Unfortunately `react-pdf` has [several](https://github.com/diegomura/react-pdf/issues/1720) [major](https://github.com/diegomura/react-pdf/issues/1271) [annoying](https://github.com/diegomura/react-pdf/issues/2003) [bugs](https://github.com/diegomura/react-pdf/issues/2017) that makes rendering SVG charts very difficult. This library attempts to ease the pain and provide a possible workaround until those bugs are fixed. +One of the best ways to generate PDFs is using [`react-pdf`](https://react-pdf.org/). Unfortunately `react-pdf` has [several](https://github.com/diegomura/react-pdf/issues/1720) [major](https://github.com/diegomura/react-pdf/issues/1271) [bugs](https://github.com/diegomura/react-pdf/issues/2017) that makes rendering SVG charts very difficult. This library attempts to ease the pain and provide a possible workaround until those bugs are fixed. ## This solution diff --git a/examples/recharts-basic.pdf b/examples/recharts-basic.pdf index b3d6077..16c8510 100644 Binary files a/examples/recharts-basic.pdf and b/examples/recharts-basic.pdf differ diff --git a/examples/recharts-composed.pdf b/examples/recharts-composed.pdf index 2b472ad..4240579 100644 Binary files a/examples/recharts-composed.pdf and b/examples/recharts-composed.pdf differ diff --git a/examples/victory-basic.pdf b/examples/victory-basic.pdf index 7bea1fd..ff4034b 100644 Binary files a/examples/victory-basic.pdf and b/examples/victory-basic.pdf differ diff --git a/src/index.tsx b/src/index.tsx index a3cb24a..0f71009 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -41,30 +41,15 @@ const renderTextElement = ({ const { attribs } = node; const { dx, dy } = getTspanChildrenOffsets(node as TagElementType); - let tSpanChildNode: JSX.Element | undefined; const textChildren = React.Children.map(children, (child) => { if (!child || typeof child === 'string') return child; - - // TSpan elements are broken in react-pdf. This will - // convert them to plain text until the issue is fixed: - // https://github.com/diegomura/react-pdf/issues/2003 - if (child.type === 'TSPAN') { - tSpanChildNode = child; - return child.props.children; - } - return child; }); - // If there's a TSpan child, we need to merge its styles with the node ones - const additionalStyle = tSpanChildNode - ? (tSpanChildNode as JSX.Element).props.style - : null; - return (