使用Pdf.js突出显示pdf内的部分 [英] Highlight a section inside pdf using Pdf.js
问题描述
我目前正在使用pdf.js进行渲染pdf的项目现在有一个棘手的任务是在给定坐标的情况下突出显示pdf页面的一部分
I'm currently using pdf.js for my project for rendering pdf Now there is this tricky task to highlight a section of pdf page given the co-ordinate
示例
给出类似的边界部分[(31,35),(40,35),(40,40),(31,40) )]
我应该突出显示给定部分选择nay主色
given a boundary section like [(31,35),(40,35),(40,40),(31,40)]
I should highlight the given section with nay primary color of choice
如何编写一个javascript来实际使用pdf.js api来完成这个任务
How to write a javascript to actually using pdf.js api to accomplish this task
是否有可能或者我是否有过野心
Is it possible or am I sounding over ambitions
推荐答案
我找到了一个更好的方法来实现这个找到html页面中点的坐标
I found a better way to achieve this find the co-ordinate of the point in the html page
然后减去<$ c的坐标(位置) $ c> div.textLayer 从中查找在线显示的pdf中文字的坐标
and then subtract the co-ordinate(position) of div.textLayer
from it to find the co-ordinate
。
为了找到实际pdf中文本的坐标,找到宽高比,你会
In order to find the co-ordinate of the text in actual pdf find the aspect ratio and you would
得到实际的co -ordinated
get the actual co-ordinate
示例
如果在线显示的pdf是 800x900
并且文本协调
if the pdf displayed online is 800x900
and the text co-ordinate
[(31,35),(40,35),(40,40),(31,40) ]
且实际的pdf大小为 612x792
and the actual pdf size is 612x792
在实际的pdf中找到该区域的适当值,如下所示
find the appropriate value of the area in actual pdf like this
(612 /(800/31)) ,(792 /(900/35))
并对在线发现的所有坐标采取这种方式
and do this way for all co-ordinate found in online
ie
(40,35),(40,40),(31,40)
可能要查看名为 convertToPdfPoint
这篇关于使用Pdf.js突出显示pdf内的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!