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:
parent
2a508b95e1
commit
9277801493
@ -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) {
|
||||
|
@ -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);
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -604,3 +604,4 @@
|
||||
!empty.pdf
|
||||
!rotated_freetexts.pdf
|
||||
!issue16633.pdf
|
||||
!bug1844576.pdf
|
||||
|
BIN
test/pdfs/bug1844576.pdf
Executable file
BIN
test/pdfs/bug1844576.pdf
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user