使用 React-pdf/renderer 和 Image 旋转我的图像
我使用react-pdf/renderer 创建了一个PDF 文件。一切都很好,但我的形象是侧面的。使用 img 标签时,它会正确显示。我尝试过搜索,发现像 onLoadSuccess 检查旋转属性这样的想法?但我不知道如何使用这个库来做到这一点。
这是我的代码:
<Document>
<Page size="A4" style={styles.page}>
<View style={styles.section}>
<View
style={{
width: "100%",
alignContent: "center",
justifyContent: "center",
padding: "10pt",
backgroundColor: "gray",
color: "white",
fontSize: "20pt",
fontWeight: "bold",
margin: 0,
}}
>
<Text style={{textAlign: "center", marginBottom: "5pt"}}>
Profile stuff here
</Text>
<Text style={{fontSize: "14pt", textAlign: "center"}}>
More profile stuff
</Text>
</View>
<View
style={{
margin: "40pt",
alignSelf: "center",
justifyContent: "center",
display: "flex",
flexDirection: "row",
flexWrap: "wrap",
}}
>
{report?.image && (
<Image
style={{
alignSelf: "center",
margin: "5pt",
maxWidth: "400pt",
maxHeight: "400pt",
width: "auto",
height: "auto",
border: 1,
}}
src={report.image}
/>
)}
</View>
</View>
</Page>
</Document>
该图像来自 Firebase,当我在那里查看时可以正确显示。我认为这与以横向或纵向模式拍摄的图像有关,但后来我迷失了。
感谢您的任何建议。
I'm created a PDF file using react-pdf/renderer. Everything is working great, but my image is sideways. When using an img tag it is shown correctly. I've tried searching and I find thoughts like onLoadSuccess check the rotate property? But I don't know how to do that using this library.
Here is my code:
<Document>
<Page size="A4" style={styles.page}>
<View style={styles.section}>
<View
style={{
width: "100%",
alignContent: "center",
justifyContent: "center",
padding: "10pt",
backgroundColor: "gray",
color: "white",
fontSize: "20pt",
fontWeight: "bold",
margin: 0,
}}
>
<Text style={{textAlign: "center", marginBottom: "5pt"}}>
Profile stuff here
</Text>
<Text style={{fontSize: "14pt", textAlign: "center"}}>
More profile stuff
</Text>
</View>
<View
style={{
margin: "40pt",
alignSelf: "center",
justifyContent: "center",
display: "flex",
flexDirection: "row",
flexWrap: "wrap",
}}
>
{report?.image && (
<Image
style={{
alignSelf: "center",
margin: "5pt",
maxWidth: "400pt",
maxHeight: "400pt",
width: "auto",
height: "auto",
border: 1,
}}
src={report.image}
/>
)}
</View>
</View>
</Page>
</Document>
The image comes from Firebase and is correctly displayed when I look at it there. I think it has something to do with the image taken in landscape or portrait mode, but then I am lost.
Thank you for any advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论