react-pdf
react-pdf copied to clipboard
Word break with numeric sequence is ignored by react-pdf rendering
Describe the bug
I using the same component with the same styling, but when I use letters [a-zA-Z] it respects the break line due to lack of space, but when I use numbers [0-1] it does not respect the width of View
To Reproduce
- Create component and render
const styles = StyleSheet.create({
body: {
paddingTop: 35,
paddingBottom: 65,
paddingHorizontal: 35,
},
textContainer: {
width: 200,
height: 100,
border: '1px solid red'
},
container: {
flex: 1,
display: 'flex',
gap: 10
}
});
const MyDocument = () => (
<Document>
<Page style={styles.body}>
<View style={styles.container}>
<View style={styles.textContainer}>
<Text>TestingTestingTestingTestingTestingTestingTestingTestingTesting</Text>
</View>
<View style={styles.textContainer}>
<Text>10101010101010101010101010101010101010</Text>
</View>
</View>
</Page>
</Document>
);
// To render the document
ReactPDF.render(<MyDocument />);
Expected behavior
I hope that the word-break of the View width spacing is respected, as happens when I use letters instead of numbers.
Is there any way around this?
Screenshots
Example in CSS3
In
CSS3exist the propertyword-breakto workaround this behavior
Desktop
- OS: Ubuntu 22.04.5 LTS
- Browser: chrome
- React-pdf version: v4.1.6
Same issue here,
Till this issue is not fixed, we can use this method, it produces similar results
<Text>
{"yourverylongnumberstring".split("").map((line, index) => (
<Text key={index}>{line}</Text>
))}
</Text>
Result: