-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
[api-minor] Include line endings in Line/Polyline Annotation-data (issue 14896) #14899
Conversation
6a682b7
to
df5c13c
Compare
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/e64279fc28e0934/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/6a86f72272c5b0d/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/e64279fc28e0934/output.txt Total script time: 3.30 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/6a86f72272c5b0d/output.txt Total script time: 7.06 mins
|
|
||
if (Array.isArray(lineEndings) && lineEndings.length === 2) { | ||
for (let i = 0, ii = lineEndings.length; i < ii; i++) { | ||
const obj = lineEndings[i]; |
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.
Just a matter of taste, but it could be shorter with something like:
if (obj instanceof Name && ["None", ...].includes(obj.name)) {
this.lineEndings[i] = obj.name;
} else {
warn(...);
}
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.
Unfortunately it doesn't actually get any shorter, it's less readable in my opinion (given the number of allowed values), and finally it'd also result in more iteration (since includes
means iterating through the array); please see the code below.
Hence I'd like to keep the existing formatting, which I essentially "borrowed" from various getters in https://github.com/mozilla/pdf.js/blob/master/src/core/catalog.js
if (
obj instanceof Name &&
[
"None",
"Square",
"Circle",
"Diamond",
"OpenArrow",
"ClosedArrow",
"Butt",
"ROpenArrow",
"RClosedArrow",
"Slash",
].includes(obj.name)
) {
this.lineEndings[i] = obj.name;
} else {
warn(`Ignoring invalid lineEnding: ${obj}`);
}
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.
LGTM.
…sue 14896) Please refer to: - https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2109792 - https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2096489 - https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2096447 Note that we still won't attempt to use the /LE-data when creating fallback appearance streams, as mentioned in PR 13448, since custom line endings aren't common enough to warrant the added complexity. Finally, note that according to the PDF specification we should *potentially* also take the line endings into account for FreeText Annotations. However, in that case their use is conditional on other parameters that we currently don't support.
df5c13c
to
6bcc5b6
Compare
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/bc5bfea34937c2e/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/c7e6194f6fc0649/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/bc5bfea34937c2e/output.txt Total script time: 3.18 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/c7e6194f6fc0649/output.txt Total script time: 7.10 mins
|
Please refer to:
Note that we still won't attempt to use the /LE-data when creating fallback appearance streams, as mentioned in PR #13448, since custom line endings aren't common enough to warrant the added complexity.
Finally, note that according to the PDF specification we should potentially also take the line endings into account for FreeText Annotations. However, in that case their use is conditional on other parameters that we currently don't support.