Text annotations must use their own canvas when their appearance is generated (bug 1844576)

When a pdf has /NeedAppearances set to true, the annotation appearance must be
generated from its value and we must take into account the hasOwnCanvas property.
This commit is contained in:
Calixte Denizet 2023-07-21 09:49:11 +02:00
parent 2a508b95e1
commit 9277801493
4 changed files with 68 additions and 2 deletions

View File

@ -1852,6 +1852,10 @@ class WidgetAnnotation extends Annotation {
return { opList, separateForm: false, separateCanvas: false };
}
const isUsingOwnCanvas = !!(
this.data.hasOwnCanvas && intent & RenderingIntentFlag.DISPLAY
);
const matrix = [1, 0, 0, 1, 0, 0];
const bbox = [
0,
@ -1877,7 +1881,7 @@ class WidgetAnnotation extends Annotation {
this.data.rect,
transform,
this.getRotationMatrix(annotationStorage),
/* isUsingOwnCanvas = */ false,
isUsingOwnCanvas,
]);
const stream = new StringStream(content);
@ -1892,7 +1896,7 @@ class WidgetAnnotation extends Annotation {
if (optionalContent !== undefined) {
opList.addOp(OPS.endMarkedContent, []);
}
return { opList, separateForm: false, separateCanvas: false };
return { opList, separateForm: false, separateCanvas: isUsingOwnCanvas };
}
_getMKDict(rotation) {

View File

@ -1963,4 +1963,65 @@ describe("Interaction", () => {
);
});
});
describe("in bug1844576.pdf", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait("bug1844576.pdf", getSelector("9R"));
});
afterAll(async () => {
await closePages(pages);
});
it("must check that a field has the correct formatted value", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const hasVisibleCanvas = await page.evaluate(_ => {
const elem = document.querySelector(
`[data-annotation-id="9R"] > canvas`
);
return elem && !elem.hasAttribute("hidden");
});
expect(hasVisibleCanvas)
.withContext(`In ${browserName}`)
.toEqual(true);
const hasHiddenInput = await page.evaluate(_ => {
const elem = document.querySelector(
`[data-annotation-id="9R"] > input`
);
return elem?.hasAttribute("hidden");
});
expect(hasHiddenInput).withContext(`In ${browserName}`).toEqual(true);
await page.click(getSelector("12R"));
await page.waitForTimeout(10);
const hasHiddenCanvas = await page.evaluate(_ => {
const elem = document.querySelector(
`[data-annotation-id="9R"] > canvas`
);
return elem?.hasAttribute("hidden");
});
expect(hasHiddenCanvas)
.withContext(`In ${browserName}`)
.toEqual(true);
const hasVisibleInput = await page.evaluate(_ => {
const elem = document.querySelector(
`[data-annotation-id="9R"] > input`
);
return elem && !elem.hasAttribute("hidden");
});
expect(hasVisibleInput)
.withContext(`In ${browserName}`)
.toEqual(true);
})
);
});
});
});

View File

@ -604,3 +604,4 @@
!empty.pdf
!rotated_freetexts.pdf
!issue16633.pdf
!bug1844576.pdf

BIN
test/pdfs/bug1844576.pdf Executable file

Binary file not shown.