Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support annotations without appearance streams #6810

Closed
timvandermeij opened this issue Dec 27, 2015 · 22 comments
Closed

Support annotations without appearance streams #6810

timvandermeij opened this issue Dec 27, 2015 · 22 comments

Comments

@timvandermeij
Copy link
Contributor

timvandermeij commented Dec 27, 2015

Most annotations, even unsupported ones, render just fine in PDF.js because of their appearance stream. However, there exist PDF files with annotations that do not have an appearance stream (even though this is a deprecated practice). In the latter case, PDF.js displays nothing. We need to have a fallback to a default appearance stream in that case, or create an appearance stream ourselves using the data present for the annotation (such as quad points and color). Below is a list of known PDF files that contain annotations without appearance streams, for which the types are listed.

@THausherr
Copy link
Contributor

THausherr commented May 21, 2016

@fancycarp
Copy link

Waiting for this feature..^^

@THausherr
Copy link
Contributor

This one has diagonal annotations. A strategy that assumes them to be horizontal will result in weird effects (try showing the file in chrome in the built-in viewer or on an Android phone with the google viewer)
https://bugs.ghostscript.com/show_bug.cgi?id=693664

@burtonator
Copy link

This is still a pretty serious issue. Apparently poppler, one of the main PDF libraries used by Okular, etc, creates annotations without appearance streams.

When loading them into PDF.js its impossible to see the annotations.

@THausherr
Copy link
Contributor

Somebody should also create an issue in poppler. The /AP is required in PDF 2.0 except for Popup, Projection or Link.

@edsontrick
Copy link

I need to add image with drag n drop. Possible solutions?

@timvandermeij
Copy link
Contributor Author

@edsontrick The question is not related to this particular issue. Please post it on IRC instead of on an unrelated issue.

@MzunguWaNjombe
Copy link

Somebody should also create an issue in poppler. The /AP is required in PDF 2.0 except for Popup, Projection or Link.

The corresponding issue for Poppler seems to be this one:
https://gitlab.freedesktop.org/poppler/poppler/issues/522

@burtonator
Copy link

Note: "Opened 9 years ago by "

... 9 years ago. Not going to be fixed anytime soon ;)

@THausherr
Copy link
Contributor

But they did work on it, there were three patch sets submitted.

@xuiqzy
Copy link

xuiqzy commented Oct 21, 2019

On the upstream poppler bug someone commented on the poppler issue tracker in response to someone saying the poppler bug would be responsible for projects using poppler not being able to properly add annotations:

It's not really our fault if pdf.js is buggy. This bug has nothing to do with what you're complaining though, so please don't hijack it.

So it seems not to be clear which project should/can fix what. As I understood it, pdf.js could render annotations without an appearance stream, but PDF software should create appearance streams, at least when making PDFs with version 2.0, right?

Maybe someone from this project like @timvandermeij or @THausherr could write a message to someone responsible in poppler to constructively clear up what poppler can and can't do to change the end user experience of not being able to show annotations created in one software when viewing in another?
That would be highly appreciated!

If that does not seem like a good idea, what can be done instead to improve the situation?

@THausherr
Copy link
Contributor

It doesn't really matter who is at fault. From a PDF 2.0 point of view, it's poppler, and from a PDF 1.* point of view, it's nobody and everyone. The head guy on poppler is "Albert Astals Cid" and he did comment on the issue so he is aware. It is useless to pressure people in OS projects on anything, the only result is that they'll feel bad. The best thing to do is to contribute yourself, if you can. I can't contribute code either, but I can help with test PDFs and strategies on the appearance content streams and giving feedback on produced PDFs because I implemented some of the annotations in Apache PDFBox.

@haxtibal
Copy link

Hi folks! Just wanted to cross link poppler issue 839, it's roughly the counter part at poppler side. No idea yet when we'll get to it though.

@timvandermeij
Copy link
Contributor Author

@haxtibal Thank you for the information! I agree that both sides need work, so Poppler should provide the appearance stream and PDF.js should be able to build the appearance stream based on the information in the data dictionary if it is missing.

@timvandermeij
Copy link
Contributor Author

Highlight, underline, squiggly and strikeout annotations without appearance streams are now supported by PDF.js thanks to the PR above. This issue remains open to track the remaining types, in particular freetext annotations.

@timvandermeij
Copy link
Contributor Author

Square and circle annotations without appearance streams are now also supported (see the PR above).

@Snuffleupagus
Copy link
Collaborator

Ink annotations without appearance streams are now also supported, see PR #13301.

@timvandermeij
Copy link
Contributor Author

timvandermeij commented Apr 27, 2021

Line annotations without appearance streams are also supported now since PR #13033.

@timvandermeij
Copy link
Contributor Author

Polyline and polygon annotations without appearance streams are also supported now since PR #13305.

@Snuffleupagus
Copy link
Collaborator

Further improvements, for many different Annotation-types without appearance streams, were made in PR #13448; these include support for opaque stroke/fill colours and handling of inconsistently specified coordinates.

@prmahima
Copy link

prmahima commented Jan 6, 2023

Is this issue being worked on?
Is there a likelihood of it being resolved this year?
Is there currently some suggested workaround?
Thanks

@Snuffleupagus
Copy link
Collaborator

FreeText annotations without appearance streams are now also supported, see PR #15587.


Is there currently some suggested workaround?

The correct thing is to generate PDF documents with appearance streams for all annotations, which is also a requirement in the PDF 2.0 specification (as far as I recall).


Given that FreeText was the primary remaining type missing here, let's close this old issue as fixed now (and further types should be evaluated/fixed separately).

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

No branches or pull requests

10 participants