I've built a search engine to find the most relevant phrases inside a document, after a user text search. After my processing I have a list of phrases texts. What I need now is to display them to the user, showing the original source PDF and scrolling it to the page where the original phrase is found. The best case scenario would be to highlight it, but for now Scrolling is enough.
我构建了一个搜索引擎,在用户文本搜索之后,在文档中找到最相关的短语。经过我的处理,我有一个短语文本列表。我现在需要的是向用户显示它们,显示原始的源PDF,并将其滚动到找到原始短语的页面。最好的情况是突出显示它,但现在滚动就足够了。
I'm using PHP and Javascript.
我用的是PHP和Javascript。
Can anyone point me a way to do this? Is there any framework available?
谁能告诉我怎么做?有可用的框架吗?
Any tips are welcome.
任何建议都是受欢迎的。
2 个解决方案
#1
5
There is an excellent JavaScript library for embedding PDFs called pdf.js. A demo can be found here
有一个很好的JavaScript库用于嵌入称为pdf.js的pdf。这里有一个演示
Out of the box, I don't think it has the highlighting and scrolling functionality you're looking for. However, it looks like someone may have figured out how to do it here
我不认为它有你想要的高亮显示和滚动功能。然而,看起来好像有人已经知道怎么做了
#2
2
If you are using Acrobat Reader to display the file in the browser, then you could use Acrobat Reader URL parameters.
如果您正在使用Acrobat Reader在浏览器中显示文件,那么您可以使用Acrobat Reader URL参数。
Example:
例子:
http://example.org/doc.pdf#page=3
There is also a post about how to embed a PDF document in a web page using Acrobat Reader
还有一篇关于如何使用Acrobat Reader在网页中嵌入PDF文档的文章
If you cannot asume that your users will use Adobe Acrobat Reader, then another option could be to use a library on the server side, then create a temporary PDF file that includes an "OpenAction" redirecting to your target page, and return that temporary file instead. The code for including this OpenAction will depend on the library that you decide to use.
如果您不能确定您的用户将使用adobeacrobatreader,那么另一个选项可以是在服务器端使用一个库,然后创建一个包含“OpenAction”重定向到目标页面的临时PDF文件,然后返回该临时文件。包含这个OpenAction的代码将取决于您决定使用的库。
#1
5
There is an excellent JavaScript library for embedding PDFs called pdf.js. A demo can be found here
有一个很好的JavaScript库用于嵌入称为pdf.js的pdf。这里有一个演示
Out of the box, I don't think it has the highlighting and scrolling functionality you're looking for. However, it looks like someone may have figured out how to do it here
我不认为它有你想要的高亮显示和滚动功能。然而,看起来好像有人已经知道怎么做了
#2
2
If you are using Acrobat Reader to display the file in the browser, then you could use Acrobat Reader URL parameters.
如果您正在使用Acrobat Reader在浏览器中显示文件,那么您可以使用Acrobat Reader URL参数。
Example:
例子:
http://example.org/doc.pdf#page=3
There is also a post about how to embed a PDF document in a web page using Acrobat Reader
还有一篇关于如何使用Acrobat Reader在网页中嵌入PDF文档的文章
If you cannot asume that your users will use Adobe Acrobat Reader, then another option could be to use a library on the server side, then create a temporary PDF file that includes an "OpenAction" redirecting to your target page, and return that temporary file instead. The code for including this OpenAction will depend on the library that you decide to use.
如果您不能确定您的用户将使用adobeacrobatreader,那么另一个选项可以是在服务器端使用一个库,然后创建一个包含“OpenAction”重定向到目标页面的临时PDF文件,然后返回该临时文件。包含这个OpenAction的代码将取决于您决定使用的库。