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

[api-minor] Include line endings in Line/Polyline Annotation-data (issue 14896) #14899

Merged
merged 1 commit into from
May 12, 2022

Conversation

Snuffleupagus
Copy link
Collaborator

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.

@Snuffleupagus Snuffleupagus changed the title [api-minor] Include line endings in Link/Polyline Annotation-data (issue 14896) [api-minor] Include line endings in Line/Polyline Annotation-data (issue 14896) May 10, 2022
@Snuffleupagus Snuffleupagus force-pushed the issue-14896 branch 3 times, most recently from 6a682b7 to df5c13c Compare May 10, 2022 16:42
@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/e64279fc28e0934/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/6a86f72272c5b0d/output.txt

@Snuffleupagus Snuffleupagus linked an issue May 10, 2022 that may be closed by this pull request
@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/e64279fc28e0934/output.txt

Total script time: 3.30 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/6a86f72272c5b0d/output.txt

Total script time: 7.06 mins

  • Unit Tests: Passed


if (Array.isArray(lineEndings) && lineEndings.length === 2) {
for (let i = 0, ii = lineEndings.length; i < ii; i++) {
const obj = lineEndings[i];
Copy link
Contributor

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(...);
}

Copy link
Collaborator Author

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}`);
}

src/core/annotation.js Outdated Show resolved Hide resolved
Copy link
Contributor

@calixteman calixteman left a 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.
@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/bc5bfea34937c2e/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/c7e6194f6fc0649/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/bc5bfea34937c2e/output.txt

Total script time: 3.18 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/c7e6194f6fc0649/output.txt

Total script time: 7.10 mins

  • Unit Tests: Passed

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

Successfully merging this pull request may close these issues.

How to get arrow annotations instead of lines?
3 participants