AngularJS - highlight text of an existing pdf file in frontend/Browser

ε祈祈猫儿з 提交于 2021-02-20 10:02:00

问题


I have found the library

PDF creation

With this library it is possible to create different styles of pdf documents. My question would be if there is a possibility to mark text (and maybe add a link to this marked text) of an existing pdf file with AngularJS? Or is there any workaround to do this?


回答1:


The question is a bit too broad as is - not sure what you mean by "mark" - do you mean highlighted in some way or actually selected?

Anyhow, firstly to get to the correct page -- you can use fragment identifiers in hyperlinks to link to a specific page in a PDF via the page parameter. e.g.

<a href="file.pdf#page=1">page 1</a>
<a href="file.pdf#page=2">page 2</a>

If you want to highlight a specific section of a page, via a hyperlink, you can use the highlight parameter, note you must also set the page to use the highlight parameter. e.g.

<a href="file.pdf#page=1&highlight=10,10,50,50">page 1 - highlight</a>

The rectangle values are integers in a coordinate system where 0,0 represents the top left, and the values are given in the order lt, rt, top, btm.

One can also open a PDF file to a "Named Destination", that is a named section in the document via the nameddest parameter. e.g.

<a href="file.pdf#nameddest=mysection">my section</a>

This is great as it doesn't matter if pages are inserted, removed etc as the section will always be correctly linked.

You can read about Named Destinations here and also the various Parameters for Opening PDF Files



来源:https://stackoverflow.com/questions/46659210/angularjs-highlight-text-of-an-existing-pdf-file-in-frontend-browser

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!