Skip to content

Implement support for Highlight annotations - #5065

Closed
timvandermeij wants to merge 1 commit into
mozilla:masterfrom
timvandermeij:popup-annotation
Closed

timvandermeij wants to merge 1 commit into
mozilla:masterfrom
timvandermeij:popup-annotation

Conversation

@timvandermeij

Copy link
Copy Markdown
Collaborator

Fixes #5018.

Highlight annotations are basically nothing more than the already implemented Text annotations. Therefore a Highlight annotation can be represented as a Text annotation according to the PDF specification at https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf#page=633&zoom=auto,-306,268.

Note that for the issue mentioned in this PR the annotations itself are fixed with this PR, but the annotation content is rotated. This is a separate issue (due to the transform on annotText that also affects child elements such as the annotation content) and I think it also related to #3826. This should be filed as a follow-up issue.

@timvandermeij

Copy link
Copy Markdown
Collaborator Author

/botio-linux preview

@pdfjsbot

Copy link
Copy Markdown

@CodingFabian

Copy link
Copy Markdown
Contributor

i checked the spec you referenced. The current pdf.js code implements a subtype called "text" but I cannot find it in the spec.
I wonder if pdf.js should also handle Underline, Squiggly, and StrikeOut the same way as well. while the rendering is not as intended the annotation would at least be there. any comments?

@timvandermeij

Copy link
Copy Markdown
Collaborator Author

@CodingFabian
The Text subtype is first mentioned here:
https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf#page=615&zoom=auto,-306,296

It is defined here:
https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf#page=621&zoom=auto,-306,554

I'm current working on a total rewrite of the annotation layer code, but I thought this patch was so easy that I would just post it so we have the support until/if the rewritten code lands (primarily because it fixes the mentioned open issue). I already have a small working version of the new code locally. It uses the abstraction used by PDFNet to get much more readable and extendable code. See http://www.pdftron.com/pdfnet/docs/PDFNetJava/pdftron/PDF/Annots/Text.html for example. I'm also aiming to add support for Underline etc. to the new code because the new code allows for these extensions much more easily by inheriting almost all properties from the parent class Text.

Why I'm rewriting the code:

  • To use separate classes for each annotation type with the advantage of inheritance of base classes.
  • To get better test coverage (at least one test file for each annotation type).
  • To support for more annotation types (because this code is easily extendable).
  • To get more readable code.
  • To get a better insight (by comparing to the spec) of what is still unimplemented and adding TODOs for that. (I found that not all missing functionality in the current implementation is mentioned in the code, which I found quite confusing and those mentions help other contributors to fill the gaps.)

@CodingFabian

Copy link
Copy Markdown
Contributor

ok, just saying that from how i read the spec, "Underline, Squiggly, and StrikeOut" are not really different from Highlight. it defines how it "looks" in the annotated text. The actual annotation could be implemented the same way.

@timvandermeij

Copy link
Copy Markdown
Collaborator Author

Right. Aside for the lay-out difference, I see no problem doing that in this PR too. At least we have the annotations then; styling can be done later.

@timvandermeij

Copy link
Copy Markdown
Collaborator Author

I'm going to close this for now. I will implement this (with the other types mentioned here) in the new framework I'm currently creating for completeness sake.

@pablox-cl

Copy link
Copy Markdown

Any news?

@timvandermeij

Copy link
Copy Markdown
Collaborator Author

No news yet, someone has to review #5585 before I can continue with my work on the annotation layer.

@hjalet

hjalet commented Jun 12, 2015

Copy link
Copy Markdown

@timvandermeij Will the work you do on the annotation layer fix the issue described in #3826?
We experience the same issue with PDFs including highlighting (it is rotated).
Highlighting is very important in our use case.

@timvandermeij

Copy link
Copy Markdown
Collaborator Author

No, my work is more focused on refactoring. This is a bugfix, so I'm not currently working on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sticky notes not viewable

5 participants