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 #15006 from calixteman/ink2

[editor] Add support for saving newly added Ink
This commit is contained in:
calixteman 2022-06-09 21:13:53 +02:00 committed by GitHub
commit 5d88233fbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 169 additions and 9 deletions

View file

@ -3859,7 +3859,7 @@ describe("annotation", function () {
});
describe("FreeTextAnnotation", () => {
it("should create an new FreeText annotation", async () => {
it("should create a new FreeText annotation", async () => {
partialEvaluator.xref = new XRefMock();
const task = new WorkerTask("test FreeText creation");
const data = await AnnotationFactory.saveNewAnnotations(
@ -3968,6 +3968,66 @@ describe("annotation", function () {
{ x: 4, y: 5 },
]);
});
it("should create a new Ink annotation", async function () {
partialEvaluator.xref = new XRefMock();
const task = new WorkerTask("test Ink creation");
const data = await AnnotationFactory.saveNewAnnotations(
partialEvaluator,
task,
[
{
annotationType: AnnotationEditorType.INK,
rect: [12, 34, 56, 78],
thickness: 1,
color: [0, 0, 0],
paths: [
{
bezier: [
10, 11, 12, 13, 14, 15, 16, 17, 22, 23, 24, 25, 26, 27,
],
points: [1, 2, 3, 4, 5, 6, 7, 8],
},
{
bezier: [
910, 911, 912, 913, 914, 915, 916, 917, 922, 923, 924, 925,
926, 927,
],
points: [91, 92, 93, 94, 95, 96, 97, 98],
},
],
},
]
);
const base = data.annotations[0].data.replace(/\(D:\d+\)/, "(date)");
expect(base).toEqual(
"1 0 obj\n" +
"<< /Type /Annot /Subtype /Ink /CreationDate (date) /Rect [12 34 56 78] " +
"/InkList [[1 2 3 4 5 6 7 8] [91 92 93 94 95 96 97 98]] /F 4 /Border [0 0 0] " +
"/Rotate 0 /AP << /N 2 0 R>>>>\n" +
"endobj\n"
);
const appearance = data.dependencies[0].data;
expect(appearance).toEqual(
"2 0 obj\n" +
"<< /FormType 1 /Subtype /Form /Type /XObject /BBox [0 0 44 44] /Length 121>> stream\n" +
"1 w\n" +
"0 G\n" +
"10 11 m\n" +
"12 13 14 15 16 17 c\n" +
"22 23 24 25 26 27 c\n" +
"S\n" +
"910 911 m\n" +
"912 913 914 915 916 917 c\n" +
"922 923 924 925 926 927 c\n" +
"S\n" +
"endstream\n" +
"\n" +
"endobj\n"
);
});
});
describe("HightlightAnnotation", function () {