在React Native中,有没有办法选择和突出显示PDF文件中的文本?

3
我是React Native的新手,我正在使用这个组件来显示PDF:https://github.com/cnjon/react-native-pdf-view。这个组件通过一个路径来打开一个PDF文件,并且使用“react-native-fs”下载PDF文件。它似乎将PDF转换为像图片一样的格式,所以我不能用这个组件选取文本,我猜测这个组件并不支持选取文本,但我不确定它在做什么。
简单地说,我想从打开的PDF中选择-高亮一个文本,并对该文本进行一些操作。有没有其他的方式或组件可以实现这个功能呢?
1个回答

0

我没有找到适合我的要求的解决方案。

我已经编写了自己的登录代码。以下是代码:

    const keywordsMarked = ["test"];
    let node = document.getElementsByClassName("your-class");
            if (node && node[0] && node[0].children[0]) {
                let a = node[0].children[0];
                if (a.children[2])
                    a.children[2].style.display = "none";
                if (a.children[1])
                    for (var i = 0; i < a.children[1].children.length; i++) {
                        console.log(a.children[1].children[i].textContent);
                        if (keywordsMarked.some(val => {
                            return a.children[1].children[i].textContent.indexOf(val) >= 0
                        })) {
                            a.children[1].children[i].style.backgroundColor = 'yellow';
                            a.children[1].children[i].style.color = 'black';
                            a.children[1].children[i].style.height = "12px";
                        }                    
                    }


            }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接