stephanrauh / ngx-extended-pdf-viewer

A full-blown PDF viewer for Angular 16, 17, and beyond
https://pdfviewer.net
Apache License 2.0
473 stars 181 forks source link

Search Multiple, Return Page Number + Coordinates, Programmatically Create Annotation, Provide Tooltip for Annotation #2090

Closed juqing27 closed 7 months ago

juqing27 commented 8 months ago

Hi @stephanrauh, I'm evaluating ngx-extended-pdf-viewer for a doc-review web app I'm building for my company and colleagues. It looks pretty amazing. There are however a few features key to our use case I'd like to confirm with you the current status - either I couldn't easily locate them in the documentation or previous discussions, or there seems to be ongoing evolvement. -

  1. Search multiple - there'll be a list of strings as the search terms, instead of just one search term. Is the findMultiple function still removed, or has "the dust settled" since #1888? :)
  2. Return page number + coordinates of search results - in the next step we'll need to create a series of annotations/markups overlapping these search results. So is it possible to return the location (page number and coordinates on page) of these search results?
  3. Programmatically Create Annotation - The "Add drawing" part is very close to what we need. Just a couple things - it looks like ngx-extended-pdf-viewer provides 2 types of standard pdf annotations currently - type 3 FreeText and type 15 Ink. If that's true, is it possible to add other types (e.g. Type 6 Square, Type 1 Text, etc.)in the near future to your library? Or is it possible for myself to define those types somewhere?
  4. Assign Unique id to annotations - we'd like to associate more info to each annotation/markup. So do the annotation/markup have a some property (id, name, tag, etc.) for this purpose (to find them later and do more things with them)?
  5. Provide tooltip to annotation/markup - Is this possible? When user hovers over them, they'll get tooltip (or other types of popup window) to show more information. - probably covered by question 3. Type 1 Text or Type 16 Popup should achieve this.
  6. Expose pdf.js? - If ngx-extended-pdf-viewer does not plan to integrate more annotating features soon, I'd like to try to use it together with this highkite pdf annotation library. However, can ngx-extended-pdf-viewer further expose pdf.js (the highkite library works with pdf.js)? Some other pdf viewer libraries do, like the "ng2-pdfjs-viewer" you mentioned as alternative (from their npm page: "what's new - Direct access to underlying viewer - Exposed PDFViewerApplication and PDFViewerApplicationOptions objects opens a whole world of customizable PDFJS and ViewerJS properties and methods..."). Wonder if it's hard to add that feature to ngx-extended-pdf-viewer too? :)

Thanks a lot for your help, Qing

juqing27 commented 7 months ago

@stephanrauh - thanks for taking a look at this! I did some research after posting this too and edited my original post. Just so you don't have to re-read the whole thing, the portions I added are - 1) whether it's possible to add more annotation types to ngx-extended-pdf-viewer, as currently it seems to support only type 3 FreeText and type 15 Ink. And 2) Is it possible to expose the underlying pdf.js?

Thanks again, Qing

stephanrauh commented 7 months ago
  1. I guess the dust has settled, but at the moment, I'm happy if I manage to keep up with the flood of bug tickets, so I don't want to implement new features now. However, I'm open to pull requests.
  2. Coordinates is difficult. The find algorithm is working on the extracted string, and it's detached from the canvas, so it simply doesn't know the coordinate. Until recently, getting the page was possible using the internal FindController. Unfortunately, nowadays every method of this class is private. But it might be a good idea to make it more accessible to users.
  3. There are also the stamp editor and the highlight editor, which is currently being developed. I'm afraid adding another annotation type requires knowledge of both pdf.js and the PDF format. In theory, you could invent a new annotation type, but nobody could read the resulting PDF file because it's non-standard. If you're ready for a deep dive, have a look at the source code: https://github.com/mozilla/pdf.js/tree/master/src/display/editor
  4. I don't want to mess up with the internal implementation of pdf.js. If you need this, you might want to ask GitHub user Calixteman. They've written a large part of the editor, so I think they are the domain expert.
  5. The latest version allows you to add an ALT text to images. Maybe that's the same idea? Otherwise, I'd like to point to you Calixteman again.
  6. The low-level API of pdf.js is available to you. The entry point if the global object PDFViewerApplication. You can find the type definitions here: https://github.com/stephanrauh/ngx-extended-pdf-viewer/tree/main/projects/ngx-extended-pdf-viewer/types. In theory, they should also be in the node_modules folder, but that seems to be broken.
stephanrauh commented 7 months ago

I'm going to close the ticket now. I like your suggestions, but as I said, I have a hard time just catching up. If you need one of the suggestions, please open a dedicated ticket. It's easier to track a collection of small tickets than tracking a big one.

Best regards, Stephan

stephanrauh commented 6 months ago

In the meantime, I've implemented a method to add images programmatically: https://pdfviewer.net/extended-pdf-viewer/annotation-layer-api