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

TypeError: Cannot read properties of undefined (reading 'top')

Open Trev-Chumba opened this issue 1 year ago • 3 comments

I have a unique issue where locally the pdf and the library works fine however after deploying it to a particular server i get the above error. Specifically if its a table and needs to move to the next page. I have no clue as to why this only appears on the test apache server.

Ive tried this so far

<View>
       <Html stylesheet={styleSheet} style={{ height: 'auto', top: 0 }}>
         {htmlData
           .replace(/<figure class="table"[^>]*>/g, '')
           .replace(/<\/figure>/g, '')
           .replace(/<figure[^>]*>/g, '')
           .replace(/vertical-align:[^;]+;/g, 'display: inline-block;')
           .replace(/rowspan/g, 'rowSpan')
           .replace(/windowtext/g, 'black')
           .replace(/height:\d+(\.\d+)?pt;/g, '')
           .replace(/<i>[^<]*<strong>[^<]*<\/strong>[^<]*<\/i>/g, (match) => {
             // Replace the combination with the Text component and custom styles
             return `<em>${match.replace(/<\/?i>/g, '').replace(/<\/?strong>/g, '')}</em>`;
           })}
       </Html>
     </View>

still nothing works The tables in question are 2tablesinHTML.txt

I have also raised this issue in the react-pdf/renderer github but this feels more like an issue with this library because the pdf works without the html data and no issues with page breaks on content written in the react-pdf/render without html data.

https://github.com/diegomura/react-pdf/issues/2804

please if you have any input i can try

Trev-Chumba avatar Jul 01 '24 08:07 Trev-Chumba

aah I am getting same problem still got no solution. image

analog-sombra avatar Jul 09 '24 08:07 analog-sombra

This seems at least partly to be an issue internal to the react-pdf library but I'm not sure what. react-pdf-html parses the text and passes down react-pdf elements. That should generally never cause an internal page break issue like that. Have you found any more clues?

danomatic avatar Jul 21 '24 21:07 danomatic

Honestly more confused but it gives the error only from a particular database but after Dropping the database and redoing the test again same data now it works.

Only glad it happened in the test server and not the real one because I still have no idea why that database was the issue or what's with that data that caused all this.

Trev-Chumba avatar Jul 26 '24 23:07 Trev-Chumba