1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-24 09:08:07 +02:00

Merge pull request #15267 from calixteman/freetext_a11y

[Annotation] Add a div containing the text of a FreeText annotation (bug 1780375)
This commit is contained in:
calixteman 2022-08-04 11:49:29 +02:00 committed by GitHub
commit b985eaa98c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 178 additions and 20 deletions

View file

@ -48,3 +48,13 @@
margin: 0;
padding: 0;
}
.annotationLayer .annotationTextContent {
position: absolute;
width: 100%;
height: 100%;
opacity: 0.4;
background-color: transparent;
color: red;
font-size: 10px;
}

View file

@ -4101,6 +4101,35 @@ describe("annotation", function () {
OPS.endAnnotation,
]);
});
it("should extract the text from a FreeText annotation", async function () {
partialEvaluator.xref = new XRefMock();
const task = new WorkerTask("test FreeText text extraction");
const freetextAnnotation = (
await AnnotationFactory.printNewAnnotations(partialEvaluator, task, [
{
annotationType: AnnotationEditorType.FREETEXT,
rect: [12, 34, 56, 78],
rotation: 0,
fontSize: 10,
color: [0, 0, 0],
value: "Hello PDF.js\nWorld !",
},
])
)[0];
await freetextAnnotation.extractTextContent(partialEvaluator, task, [
-Infinity,
-Infinity,
Infinity,
Infinity,
]);
expect(freetextAnnotation.data.textContent).toEqual([
"Hello PDF.js",
"World !",
]);
});
});
describe("InkAnnotation", function () {