diegomura / react-pdf

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

Is there a way to make a View both wrap={false} and fixed? #2694

Open pietroanello opened 1 month ago

pietroanello commented 1 month ago

Describe the bug I'm trying to have a couple of consecutives "tables". The table Header should be fixed for every page where the content extend, but at the same time should go to the next page if the remaining space between two consecutive tables is not enough to contain it.

To Reproduce Steps to reproduce the behavior including code snippet (if applies):

const styles = StyleSheet.create({
  page: { padding: 20, paddingBottom: 0 },
 header: {height: 90, backgroundColor: 'red'},
  header2: {height: 90, backgroundColor: 'green'}
});

const doc = (
  <Document>
    <Page style={styles.page} size="A4">
      <View>
        <View style={styles.header} fixed wrap={false} debug />
        <View>
            {Array.from(Array(70).keys()).map(k => <Text>{k}</Text>)}
        </View>
      </View>

      <View>
        <View style={styles.header2} fixed wrap={false} debug />
        <View>
            {Array.from(Array(70).keys()).map(k => <Text>{k}</Text>)}
        </View>
      </View>
    </Page>
  </Document>
);

ReactPDF.render(doc);

Expected behavior The second header should go to the next page and not cutting himself at the end of the previous.

Screenshots Screenshot 2024-03-27 alle 12 20 10

Desktop (please complete the following information):