diegomura / react-pdf

📄 Create PDF files using React
https://react-pdf.org
MIT License
14.95k stars 1.18k forks source link

Hangs when Image goes off page #2242

Open joshualoehr opened 1 year ago

joshualoehr commented 1 year ago

Describe the bug Page crashes/hangs when Images overflow off the page, instead of starting on the next page.

To Reproduce Reproducable in the repl using the code snippet below. Just change the value of top from 100 to 600 or greater.

ReactPDF.render((
  <Document>
    <Page size="A4" wrap>
      <Image src="/images/quijote1.jpg" style={{top: 100}}/>
    </Page>
  </Document>
));

Possibly related to #874?

Expected behavior The Image starts rendering on a new page.

Desktop (please complete the following information):

jamesricky commented 1 year ago

The same issue occurs when the image is moved down by a fixed View, that causes the image to overflow the page.
Here is a CodeSandbox to reproduce the problem: https://codesandbox.io/s/react-pdf-crash-when-rendering-too-high-images-9ok4us?file=/src/index.js Setting the bottomImageHeight to 650 will cause the renderer to crash/hang.

Interestingly the page renders without any issues when the image is not moved down by a top position or a fixed View, even if the image has more height than the page and overflows.