const Template1 = ({ data }) => {
const styles = StyleSheet.create({
page: {
position: "relative",
},
watermarkContainer: {
position: "absolute",
bottom: 30,
right: 30,
zIndex: 0,
opacity: 0.5,
},
watermark: {
width: 120,
},
});
return (
<Document>
<Page size="A4" style={styles.page}>
<Text>{data}</Text>
<View style={styles.watermarkContainer}>
<Image src={Watermark} />
</View>
</Page>
</Document>
);
};
If the content in the page tag fills multiple pages, the watermark only shows on the last page. How can I add a watermark on every page?
const Template1 = ({ data }) => {
const styles = StyleSheet.create({
page: {
position: "relative",
},
watermarkContainer: {
position: "absolute",
bottom: 30,
right: 30,
zIndex: 0,
opacity: 0.5,
},
watermark: {
width: 120,
},
});
return (
<Document>
<Page size="A4" style={styles.page}>
<Text>{data}</Text>
<View style={styles.watermarkContainer}>
<Image src={Watermark} />
</View>
</Page>
</Document>
);
};
If the content in the page tag fills multiple pages, the watermark only shows on the last page. How can I add a watermark on every page?
Share Improve this question edited Feb 17 at 12:29 Dhamodharan B asked Feb 17 at 12:23 Dhamodharan BDhamodharan B 111 bronze badge New contributor Dhamodharan B is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 2 |1 Answer
Reset to default 1You can do it by leveraging canvasRef
and drawing over the PDF yourself. This is how you can do it:
https://codesandbox.io/p/sandbox/react-pdf-watermark-5wylx?file=%2Findex.html
react-pdf
stackoverflow/questions/50366481/… – evolutionxbox Commented Feb 17 at 12:44