-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Let non-viewable Popup Annotations inherit the parent's Annotation Flags if the parent is viewable #7352
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
Let non-viewable Popup Annotations inherit the parent's Annotation Flags if the parent is viewable #7352
Conversation
I think the general idea here is fine. Okular is also able to properly view this file, so I think it makes sense to fix this since other viewers can work with this PDF, even though (luckily) it's very much an edge case. The situation where the parent is visible but the popup is not is sufficiently rare that I'm not worried about breakage in other areas. I followed the specification closely when I implemented this initially, so I'm also pretty sure that this case is not outlined in the specification, unfortunately. |
@@ -55,6 +55,22 @@ var ObjectLoader = coreObj.ObjectLoader; | |||
var FileSpec = coreObj.FileSpec; | |||
var OperatorList = coreEvaluator.OperatorList; | |||
|
|||
function hasFlag(flags, bit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep these functions inside the class, but instead access them via private methods? So, get viewable()
would use return this._isViewable(this.flags)
and _isViewable
is a private method of the Annotation
class. It seems to make sense to me to keep this inside the Annotation
class as that is where they operate on. All other classes inherit from Annotation
, so they will also have these private methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep these functions inside the class, but instead access them via private methods?
Of course we can, thanks for suggesting this!
I wasn't entirely happy about moving that code out of the Annotation
class, so nice idea :-)
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.22.172.223:8877/30f4ff2591541c6/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/b8993376283081c/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/30f4ff2591541c6/output.txt Total script time: 21.26 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/b8993376283081c/output.txt Total script time: 27.48 mins
|
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/cb15ea7a0a32711/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/cb15ea7a0a32711/output.txt Total script time: 1.03 mins Published |
@@ -191,27 +191,48 @@ var Annotation = (function AnnotationClosure() { | |||
|
|||
Annotation.prototype = { | |||
/** | |||
* @private | |||
*/ | |||
_hasFlag: function Annotation_isViewable(flags, flag) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Annotation_hasFlag
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, fixed now.
…ags if the parent is viewable Fixes http://www.pdf-archive.com/2013/09/30/file2/file2.pdf. Note how it's not possible to show the various Popup Annotations in the above document. To fix that, this patch lets the Popup inherit the flags of the parent, in the special case where the parent is `viewable` *and* the Popup is not. In general, I don't think that a Popup must have the same flags set as the parent. However, it seems very strange to have a `viewable` parent annotation, and then not being able to view the Popup. Annoyingly the PDF specification doesn't, as far as I can find, mention anything about how this case should be handled, but this patch seem consistent with the actual behaviour in Adobe Reader.
/botio makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/354c2e12d53a6b0/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_makeref from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/8773c81b7651ae1/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/354c2e12d53a6b0/output.txt Total script time: 21.14 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/8773c81b7651ae1/output.txt Total script time: 26.47 mins
|
Thank you for working on this! |
Fixes http://www.pdf-archive.com/2013/09/30/file2/file2.pdf.
Note how it's not possible to show the various Popup Annotations in the above document.
To fix that, this patch lets the Popup inherit the flags of the parent, in the special case where the parent is
viewable
and the Popup is not.In general, I don't think that a Popup must have the same flags set as the parent. However, it seems very strange to have a
viewable
parent annotation, and then not being able to view the Popup.Annoyingly the PDF specification doesn't, as far as I can find, mention anything about how this case should be handled, but this patch seem consistent with the actual behaviour in Adobe Reader.
@timvandermeij How do you feel about this patch? Should we consider fixing this edge-case, or are we more worried about breakage elsewhere.
Please note: I've not attached a test-case, nor run the tests, since I wanted feedback on the general idea of the patch before spending a lot of time on this.