如何向react-pdf文档添加样式
我尝试使用此代码,但无法调整宽度
<前><代码> <文档 样式={{宽度:“100px”}} 文件=“123.pdf” onLoadSuccess={onDocumentLoadSuccess} > <页pageNumber={pageNumber} />
I tried with this code and cannot adjust the width
<Document style={{width:"100px"}} file="123.pdf" onLoadSuccess={onDocumentLoadSuccess} > <Page pageNumber={pageNumber} /> </Document>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
style={{}} 不起作用。 React-pdf 没有宽度属性。但有一个高度属性。我使用了它,并根据比例调整了宽度。这对我有用。
style={{}} was not working. react-pdf has no width property. But there was a height property. I used that and according to ratio it adjusted the width as well. It worked for me.
根据文档 https://react-pdf.org/components 不支持样式,需要对page组件进行样式设置
According to the documentation https://react-pdf.org/components does not support style, you need to style the page component
您需要删除 (px) 保留为数字或字符串,而不带 px =>;宽度:“100”或宽度:100
you need to remove (px) keep as a number or string without px => width: "100" or width: 100