1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

[Editor] Add support for printing newly added Ink annotations

This commit is contained in:
Calixte Denizet 2022-06-15 16:57:33 +02:00
parent 8d466f5dac
commit f27c8c4471
6 changed files with 271 additions and 94 deletions

View file

@ -6622,5 +6622,49 @@
"rotation": 270
}
}
},
{
"id": "tracemonkey-editor",
"file": "pdfs/tracemonkey.pdf",
"md5": "9a192d8b1a7dc652a19835f6f08098bd",
"rounds": 1,
"lastPage": 1,
"type": "eq",
"print": true,
"annotationStorage": {
"pdfjs_internal_editor_0": {
"annotationType": 3,
"color": [0, 0, 0],
"fontSize": 10,
"value": "Hello World",
"pageIndex": 0,
"rect": [67.5, 543, 119, 556.5],
"orderIndex": 0
},
"pdfjs_internal_editor_1": {
"annotationType": 15,
"color": [255, 0, 0],
"thickness": 3,
"paths": [{
"bezier": [
1.5, 25.727771084724367, 2.8040804485100495, 27.031851533234402,
5.396811581133676, 23.25556095123241, 6, 22.727771084724367,
10.45407020558315, 18.830459654839103, 15.981183968598401,
16.364531104350363, 21, 13.227771084724367, 25.88795894206055,
10.172796745936523, 37.988543516372076, 5.739227568352277, 42,
1.7277710847243668
],
"points": [
1.5, 25.727771084724367, 5.225791198862495, 23.602568747729173,
4.012834511116397, 24.914722452856147, 6, 22.727771084724367, 21,
13.227771084724367, 37.71378602219673, 4.78737352236285,
31.828688421912233, 7.836451889039392, 42, 1.7277710847243668
]
}],
"pageIndex": 0,
"rect": [71.5, 534.5, 115, 562],
"orderIndex": 1
}
}
}
]

View file

@ -4186,6 +4186,58 @@ describe("annotation", function () {
"endobj\n"
);
});
it("should render an added Ink annotation for printing", async function () {
partialEvaluator.xref = new XRefMock();
const task = new WorkerTask("test Ink printing");
const inkAnnotation = (
await AnnotationFactory.printNewAnnotations(partialEvaluator, task, [
{
annotationType: AnnotationEditorType.INK,
rect: [12, 34, 56, 78],
thickness: 1,
color: [0, 0, 0],
paths: [
{
bezier: [1, 2, 3, 4, 5, 6, 7, 8],
// Useless in the printing case.
points: [1, 2, 3, 4, 5, 6, 7, 8],
},
],
},
])
)[0];
const operatorList = await inkAnnotation.getOperatorList(
partialEvaluator,
task,
RenderingIntentFlag.PRINT,
false,
null
);
expect(operatorList.argsArray.length).toEqual(6);
expect(operatorList.fnArray).toEqual([
OPS.beginAnnotation,
OPS.setLineWidth,
OPS.setStrokeRGBColor,
OPS.constructPath,
OPS.stroke,
OPS.endAnnotation,
]);
// Linewidth.
expect(operatorList.argsArray[1]).toEqual([1]);
// Color.
expect(operatorList.argsArray[2]).toEqual(
new Uint8ClampedArray([0, 0, 0])
);
// Path.
expect(operatorList.argsArray[3][0]).toEqual([OPS.moveTo, OPS.curveTo]);
expect(operatorList.argsArray[3][1]).toEqual([1, 2, 3, 4, 5, 6, 7, 8]);
// Min-max.
expect(operatorList.argsArray[3][2]).toEqual([1, 1, 2, 2]);
});
});
describe("HightlightAnnotation", function () {