admin管理员组文章数量:1244246
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
本文标签: javascriptHow to add watermark to every pages in reactpdfStack Overflow
版权声明:本文标题:javascript - How to add watermark to every pages in react-pdf - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740159965a2234242.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
react-pdf
stackoverflow/questions/50366481/… – evolutionxbox Commented Feb 17 at 12:44