如何向react-pdf文档添加样式

发布于 2025-01-11 21:07:43 字数 368 浏览 2 评论 0原文

  1. 我尝试使用此代码,但无法调整宽度

    <前><代码> <文档 样式={{宽度:“100px”}} 文件=“123.pdf” onLoadSuccess={onDocumentLoadSuccess} > <页pageNumber={pageNumber} />
  1. I tried with this code and cannot adjust the width

                            <Document
                                style={{width:"100px"}}
                                file="123.pdf"
                                onLoadSuccess={onDocumentLoadSuccess}
                            >
                                <Page pageNumber={pageNumber} />
                            </Document>
    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

平生欢 2025-01-18 21:07:43

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.

一笔一画续写前缘 2025-01-18 21:07:43

根据文档 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

雨落□心尘 2025-01-18 21:07:43

您需要删除 (px) 保留为数字或字符串,而不带 px =>;宽度:“100”或宽度:100

you need to remove (px) keep as a number or string without px => width: "100" or width: 100

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文