Rotate annotations based on the MK::R value (bug 1675139)

- it aims to fix: https://bugzilla.mozilla.org/show_bug.cgi?id=1675139;
- An annotation can be rotated (counterclockwise);
- the rotation can be set in using JS.
This commit is contained in:
Calixte Denizet 2022-06-19 16:39:54 +02:00
parent 54777b42c2
commit cdc58b7a52
10 changed files with 562 additions and 78 deletions

View file

@ -57,7 +57,6 @@ class Field extends PDFObject {
this.required = data.required;
this.richText = data.richText;
this.richValue = data.richValue;
this.rotation = data.rotation;
this.style = data.style;
this.submitName = data.submitName;
this.textFont = data.textFont;
@ -84,6 +83,7 @@ class Field extends PDFObject {
this._kidIds = data.kidIds || null;
this._fieldType = getFieldType(this._actions);
this._siblings = data.siblings || null;
this._rotation = data.rotation || 0;
this._globalEval = data.globalEval;
this._appObjects = data.appObjects;
@ -188,6 +188,22 @@ class Field extends PDFObject {
throw new Error("field.page is read-only");
}
get rotation() {
return this._rotation;
}
set rotation(angle) {
angle = Math.floor(angle);
if (angle % 90 !== 0) {
throw new Error("Invalid rotation: must be a multiple of 90");
}
angle %= 360;
if (angle < 0) {
angle += 360;
}
this._rotation = angle;
}
get textColor() {
return this._textColor;
}