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

Issue about rendering PDF annotation/comment #6564

Closed
fancycarp opened this issue Oct 26, 2015 · 13 comments
Closed

Issue about rendering PDF annotation/comment #6564

fancycarp opened this issue Oct 26, 2015 · 13 comments

Comments

@fancycarp
Copy link

I merged the annotations from FDF file into PDF file using iTextSharp 5.5.0.0
and all annotations were not rendered.
*Tested with pdfjs-1.1.366

Right screen is the expected result (Opened in Adobe Reader CC)
mwsnap 2015-10-26 10_11_32

When I re-save file (with annotation) using Adobe Reader CC, annotations do appear in PDFJS like this
mwsnap 2015-10-26 10_34_42

Please check the related sample files :
Original PDF
https://drive.google.com/file/d/0B-_5BgJGB33EX3BUbDBuQkI3Rlk/view

FDF File
https://drive.google.com/file/d/0B-_5BgJGB33EM3JLT0NocDFDMFU/view

With Annotation
https://drive.google.com/file/d/0B-_5BgJGB33Ea2dQZnpUY2FvYkk/view

With Annotation (Re-save by Reader CC)
https://drive.google.com/file/d/0B-_5BgJGB33EaXl0MVVkMThBNzQ/view

Thank you

@yurydelendik
Copy link
Contributor

Looks like Google Docs, Chrome and Mac OSX Preview has issue with this file as well. Are you sure that iTextSharp does not produce the corrupted PDF?

@yurydelendik
Copy link
Contributor

The last file looks fine Firefox and Edge on Windows and Firefox and Chrome on OSX. So the last screenshot shows defect on Chrome for Windows.

There are two issues: corrupted PDF ("Original PDF") and upstream Chrome defect ("With Annotation (Re-save by Reader CC)").

@yurydelendik
Copy link
Contributor

Upstream issue https://code.google.com/p/chromium/issues/detail?id=552080 (cc @Rob--W)

Making this issue only about corrupted PDF.

@fancycarp
Copy link
Author

It's possible that iTextSharp produce corrupted PDF. I'm searching some tool to analyze corrupted PDF. But Adobe Reader CC and Foxit Reader still can render it ("With Annotation"). So I hope PDF js can do that too. ^^

@fancycarp
Copy link
Author

I don't think the file ("With Annotation") is corrupted.
Three PDF readers (Adobe Reader DC, Foxit Reader, PDF Exchange Viewer) can render it correctly.
mwsnap 2015-11-16 15_50_43

@xlc
Copy link
Contributor

xlc commented Nov 16, 2015

This issue is that some annotations (line, circle and square) are not fully supported.

From console log

Warning: Unimplemented annotation type "FreeText", falling back to base annotation
Warning: Unimplemented annotation type "Square", falling back to base annotation
Warning: Unimplemented annotation type "Circle", falling back to base annotation
Warning: Unimplemented annotation type "Line", falling back to base annotation

So PDF.js fallback to use base annotation implementation to render them, which means it is rendering those annotations use its AP field (appearance stream). Most of the PDF reader/editor generates this filed by default. That's why resave the file using some reader will fixes the file. However because this field is optional, some PDF tool (iText) may generate the annotation without this field, then the fallback rendering no longer works.

Implement those annotations should be very easy, but may be blocked by #5218

@Rob--W
Copy link
Member

Rob--W commented Dec 15, 2015

The upstream bug (https://crbug.com/552080) has been fixed. This fix will be available in Chrome 49. Once Skia has rolled and a Canary update has been published, could you check whether the bug is fixed in Canary and close this bug if possible?

@fancycarp
Copy link
Author

By using Chrome 49.0.2599.0 + PDF JS Extension (v1.1.527) on Windows 8.0

Opening the last file looks OK. The bug is fixed.
With Annotation (Re-save by Reader CC)
https://drive.google.com/file/d/0B-_5BgJGB33EaXl0MVVkMThBNzQ/view

But, actually, I hope PDF JS can render annotation in the third file
With Annotation
https://drive.google.com/file/d/0B-_5BgJGB33Ea2dQZnpUY2FvYkk/view

(the re-saved file is just my curious to know what happen when re-save) :

So, I request PDF JS team to do rendering default appearance stream like other PDF readers do. (mentioned by xlc). You have the plan to implement them, right?

@chitgoks
Copy link

chitgoks commented Mar 6, 2016

i have a question.in this sample pdf.js shows annotations created in adobe acrobat.

but there is currently no way to get other details like comments, coordinates, right?

@timvandermeij
Copy link
Contributor

timvandermeij commented Mar 13, 2021

The problem with the WithComment.pdf file is indeed that the annotations don't have appearance streams defined, so #6564 (comment) is completely right. PDF.js now renders the square and circle annotations correctly after pull request #13031. Strangely, line annotations without appearance streams are also supported after pull request #13033, but this particular line annotation doesn't render. Free text annotations are not yet supported.

This is therefore largely a duplicate of #6810 aside from the line annotation issue.

@Snuffleupagus
Copy link
Collaborator

Strangely, line annotations without appearance streams are also supported after pull request #13033, but this particular line annotation doesn't render.

My guess is that it's connected to, and/or caused by, the bogus entry /Rect = [0, 0, 0, 0] since that causes the computed /BBox to be completely off. Perhaps it's possible to somehow use the /L entry (suitably transformed) as a stand-in for the /Rect in that case?

@THausherr
Copy link
Contributor

Yes. Adobe Reader changes the /Rect entry accordingly.

@timvandermeij
Copy link
Contributor

Closing since pull request #13106 fixed the line annotation too, so only the free text annotation is left which is tracked in #6810.

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

8 participants