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

Support rotating editor layer

- As in the annotation layer, use percent instead of pixels as unit;
- handle the rotation of the editor layer in allowing editing when rotation
  angle is not zero;
- the different editors are rotated counterclockwise in order to be usable
  when the main page is itself rotated;
- add support for saving/printing rotated editors.
This commit is contained in:
Calixte Denizet 2022-06-23 15:47:45 +02:00
parent b5fea8ff14
commit 0c420f5135
13 changed files with 473 additions and 159 deletions

View file

@ -1413,7 +1413,7 @@ describe("Interaction", () => {
await closePages(pages);
});
it("must check that data-annotation-rotation is correct", async () => {
it("must check that data-main-rotation is correct", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForFunction(
@ -1431,7 +1431,7 @@ describe("Interaction", () => {
]) {
const rotation = await page.$eval(
`[data-annotation-id='${ref}R']`,
el => parseInt(el.getAttribute("data-annotation-rotation") || 0)
el => parseInt(el.getAttribute("data-main-rotation") || 0)
);
expect(rotation)
.withContext(`In ${browserName}`)

View file

@ -6638,7 +6638,8 @@
"fontSize": 10,
"value": "Hello World",
"pageIndex": 0,
"rect": [67.5, 543, 119, 556.5]
"rect": [67.5, 543, 119, 556.5],
"rotation": 0
},
"pdfjs_internal_editor_1": {
"annotationType": 15,
@ -6661,8 +6662,164 @@
]
}],
"pageIndex": 0,
"rect": [71.5, 534.5, 115, 562]
"rect": [71.5, 534.5, 115, 562],
"rotation": 0
}
}
},
{
"id": "tracemonkey-editor-rotation",
"file": "pdfs/tracemonkey.pdf",
"md5": "9a192d8b1a7dc652a19835f6f08098bd",
"rounds": 1,
"lastPage": 1,
"type": "eq",
"print": true,
"annotationStorage": {
"pdfjs_internal_editor_3": {
"annotationType": 3,
"color": [0, 0, 0],
"fontSize": 10,
"value": "Hello",
"pageIndex": 0,
"rect": [
96.34615384615385, 554.8461538461538, 119.12498076923077,
568.3461538461538
],
"rotation": 0
},
"pdfjs_internal_editor_4": {
"annotationType": 3,
"color": [0, 0, 0],
"fontSize": 10,
"value": "PDF",
"pageIndex": 0,
"rect": [
125.57692307692308, 533.5384615384615, 139.07692307692307,
553.5384807692308
],
"rotation": 90
},
"pdfjs_internal_editor_5": {
"annotationType": 3,
"color": [0, 0, 0],
"fontSize": 10,
"value": ".js",
"pageIndex": 0,
"rect": [
105.9615576923077, 535.0769230769231, 115.96153846153847,
548.5769230769231
],
"rotation": 180
},
"pdfjs_internal_editor_6": {
"annotationType": 3,
"color": [0, 0, 0],
"fontSize": 10,
"value": "world!",
"pageIndex": 0,
"rect": [
77.84615384615385, 531.682673076923, 91.34615384615385,
558.3461538461538
],
"rotation": 270
},
"pdfjs_internal_editor_21": {
"annotationType": 15,
"color": [0, 0, 0],
"thickness": 1,
"paths": [
{
"bezier": [
0.5, 15.653846153846189, 0.5, 10.612792605955292,
2.221156193659856, 5.960961418318131, 2.221156193659856,
0.7371591421274406
],
"points": [
0.5, 15.653846153846189, 2.221156193659856, 0.7371591421274406
]
}
],
"pageIndex": 0,
"rect": [
416.53846153846155, 561.8076923076923, 419.41346388596753,
577.9615384615385
],
"rotation": 0
},
"pdfjs_internal_editor_23": {
"annotationType": 15,
"color": [0, 0, 0],
"thickness": 1,
"paths": [
{
"bezier": [
0.5, 18.538461538461547, 0.5, 12.869221974582576,
3.9307267310416893, 5.207607308237302, 1.6538461538461537,
0.653846153846164
],
"points": [
0.5, 18.538461538461547, 2.434116685812059, 4.572198481030599,
1.9307532933714027, 9.17784944259592, 1.6538461538461537,
0.653846153846164
]
}
],
"pageIndex": 0,
"rect": [
390.00000000000006, 543.4615384615386, 409.0384615384616,
546.9134638859676
],
"rotation": 90
},
"pdfjs_internal_editor_25": {
"annotationType": 15,
"color": [0, 0, 0],
"thickness": 1,
"paths": [
{
"bezier": [
0.5, 24.307692307692264, 0.5, 16.218230266280443,
1.6442331167367787, 8.976323168614734, 1.6442331167367787,
0.8509134145882982
],
"points": [
0.5, 24.307692307692264, 1.6442331167367787, 0.8509134145882982
]
}
],
"pageIndex": 0,
"rect": [
422.7788438063401, 515.7692307692307, 425.07692307692304,
540.576923076923
],
"rotation": 180
},
"pdfjs_internal_editor_27": {
"annotationType": 15,
"color": [0, 0, 0],
"thickness": 1,
"paths": [
{
"bezier": [
0.5, 32.96153846153845, 4.262222952239026, 32.96153846153845,
2.8076923076923075, 4.355429108316972, 2.8076923076923075,
0.6538461538461462
],
"points": [
0.5, 32.96153846153845, 2.9761779872739975, 7.263528385840449,
3.0646797609357885, 18.195785915618856, 2.8076923076923075,
0.6538461538461462
]
}
],
"pageIndex": 0,
"rect": [
425.6538461538462, 553.7403822678785, 459.11538461538464,
557.7692307692307
],
"rotation": 270
}
}
}
]

View file

@ -4027,6 +4027,7 @@ describe("annotation", function () {
{
annotationType: AnnotationEditorType.FREETEXT,
rect: [12, 34, 56, 78],
rotation: 0,
fontSize: 10,
color: [0, 0, 0],
value: "Hello PDF.js World!",
@ -4078,6 +4079,7 @@ describe("annotation", function () {
{
annotationType: AnnotationEditorType.FREETEXT,
rect: [12, 34, 56, 78],
rotation: 0,
fontSize: 10,
color: [0, 0, 0],
value: "A",
@ -4181,6 +4183,7 @@ describe("annotation", function () {
{
annotationType: AnnotationEditorType.INK,
rect: [12, 34, 56, 78],
rotation: 0,
thickness: 1,
color: [0, 0, 0],
paths: [
@ -4239,6 +4242,7 @@ describe("annotation", function () {
{
annotationType: AnnotationEditorType.INK,
rect: [12, 34, 56, 78],
rotation: 0,
thickness: 1,
color: [0, 0, 0],
paths: [