Skip to content

Commit 262a1f9

Browse files
authored
Merge pull request #19881 from calixteman/bug1963407
Fix the bbox when saving a rotated text field (bug 1963407)
2 parents c1a398d + 7a251b2 commit 262a1f9

5 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/core/annotation.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,11 @@ class WidgetAnnotation extends Annotation {
22482248
const appearanceDict = (appearanceStream.dict = new Dict(xref));
22492249
appearanceDict.set("Subtype", Name.get("Form"));
22502250
appearanceDict.set("Resources", resources);
2251-
appearanceDict.set("BBox", [0, 0, this.width, this.height]);
2251+
const bbox =
2252+
rotation % 180 === 0
2253+
? [0, 0, this.width, this.height]
2254+
: [0, 0, this.height, this.width];
2255+
appearanceDict.set("BBox", bbox);
22522256

22532257
const rotationMatrix = this.getRotationMatrix(annotationStorage);
22542258
if (rotationMatrix !== IDENTITY_MATRIX) {

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,3 +723,4 @@
723723
!issue18529.pdf
724724
!issue16742.pdf
725725
!chrome-text-selection-markedContent.pdf
726+
!bug1963407.pdf

test/pdfs/bug1963407.pdf

6.33 KB
Binary file not shown.

test/test_manifest.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12093,5 +12093,19 @@
1209312093
"md5": "98b19e944339c01c10c503685eee3ad2",
1209412094
"rounds": 1,
1209512095
"type": "eq"
12096+
},
12097+
{
12098+
"id": "bug1963407",
12099+
"file": "pdfs/bug1963407.pdf",
12100+
"md5": "49d3d2dd42014d978af6e6ad814e5e64",
12101+
"rounds": 1,
12102+
"type": "eq",
12103+
"save": true,
12104+
"print": true,
12105+
"annotationStorage": {
12106+
"24R": {
12107+
"value": "Hello World"
12108+
}
12109+
}
1209612110
}
1209712111
]

test/unit/annotation_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,7 @@ describe("annotation", function () {
22572257
);
22582258
expect(newData.data).toEqual(
22592259
"2 0 obj\n<< /Subtype /Form /Resources " +
2260-
"<< /Font << /Helv 314 0 R>>>> /BBox [0 0 32 10] /Matrix [0 1 -1 0 32 0] /Length 74>> stream\n" +
2260+
"<< /Font << /Helv 314 0 R>>>> /BBox [0 0 10 32] /Matrix [0 1 -1 0 32 0] /Length 74>> stream\n" +
22612261
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2 2.94 Td (hello world) Tj " +
22622262
"ET Q EMC\nendstream\nendobj\n"
22632263
);
@@ -3808,7 +3808,7 @@ describe("annotation", function () {
38083808
[
38093809
"2 0 obj",
38103810
"<< /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " +
3811-
"/BBox [0 0 32 10] /Matrix [0 -1 1 0 0 10] /Length 170>> stream",
3811+
"/BBox [0 0 10 32] /Matrix [0 -1 1 0 0 10] /Length 170>> stream",
38123812
"/Tx BMC q",
38133813
"1 1 10 32 re W n",
38143814
"0.600006 0.756866 0.854904 rg",

0 commit comments

Comments
 (0)