Skip to content

Commit

Permalink
Don't get the text content for an annotation when /NeedAppearances is…
Browse files Browse the repository at this point in the history
… true (bug 1844583)

When the flag is set, the appearance has to be generated from the value so it's
useless/meaningless to extract the content from the existing appearance.
  • Loading branch information
calixteman authored and pull[bot] committed Aug 18, 2024
1 parent d6bfe17 commit 1337429
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2572,7 +2572,7 @@ class TextWidgetAnnotation extends WidgetAnnotation {
}

get hasTextContent() {
return !!this.appearance;
return !!this.appearance && !this._needAppearances;
}

_getCombAppearance(
Expand Down
28 changes: 28 additions & 0 deletions test/integration/annotation_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,4 +508,32 @@ describe("ResetForm action", () => {
});
});
});

describe("Don't use AP when /NeedAppearances is true", () => {
describe("bug1844583.pdf", () => {
let pages;

beforeAll(async () => {
pages = await loadAndWait(
"bug1844583.pdf",
"[data-annotation-id='8R']"
);
});

afterAll(async () => {
await closePages(pages);
});

it("must check the content of the text field", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const text = await page.$eval(getSelector("8R"), el => el.value);
expect(text)
.withContext(`In ${browserName}`)
.toEqual("Hello World");
})
);
});
});
});
});
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -605,3 +605,4 @@
!rotated_freetexts.pdf
!issue16633.pdf
!bug1844576.pdf
!bug1844583.pdf
Binary file added test/pdfs/bug1844583.pdf
Binary file not shown.

0 comments on commit 1337429

Please sign in to comment.