【问题标题】:react-pdf text renders in different positionsreact-pdf 文本呈现在不同的位置
【发布时间】:2021-10-04 05:31:58
【问题描述】:

我试图在我的项目中使用 react-pdf 在我的页面上显示希伯来语 pdf 文件。我还想通过链接到其他页面(如维基百科)使某些单词可点击。我正在尝试像这样使用 customTextRenderer(仅以单词“על”为例):

            customTextRenderer={({ str, itemIndex }) => (
                str
                  .split('על')
                  .reduce((strArray, currentValue, currentIndex) => (
                    currentIndex === 0
                      ? ([...strArray, currentValue])
                      : ([...strArray, (
                        // eslint-disable-next-line react/no-array-index-key
                        <a href="/whatever" key={currentIndex}>
                            על
                        </a>
                      ), currentValue])
                  ), []))}

这是结果(小sn-p):

您可以看到第一个单词“על”在原始单词的右侧,但下一个实例位于它的左侧。他们离左边的距离也不一样,所以这很奇怪。请问有什么建议吗?

【问题讨论】:

    标签: reactjs pdf text hyperlink react-pdf


    【解决方案1】:

    找到的解决方案:添加方向:仅在跨度上从右到左。

    .react-pdf__Page__textContent span {
        direction: rtl;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-15
      • 2022-10-20
      相关资源
      最近更新 更多