Fix the bbox when saving a rotated text field (bug 1963407)

This commit is contained in:
Calixte Denizet 2025-04-29 18:27:07 +02:00
parent 2e10ff6dd4
commit 7a251b206e
5 changed files with 22 additions and 3 deletions

View File

@ -2248,7 +2248,11 @@ class WidgetAnnotation extends Annotation {
const appearanceDict = (appearanceStream.dict = new Dict(xref));
appearanceDict.set("Subtype", Name.get("Form"));
appearanceDict.set("Resources", resources);
appearanceDict.set("BBox", [0, 0, this.width, this.height]);
const bbox =
rotation % 180 === 0
? [0, 0, this.width, this.height]
: [0, 0, this.height, this.width];
appearanceDict.set("BBox", bbox);
const rotationMatrix = this.getRotationMatrix(annotationStorage);
if (rotationMatrix !== IDENTITY_MATRIX) {

View File

@ -723,3 +723,4 @@
!issue18529.pdf
!issue16742.pdf
!chrome-text-selection-markedContent.pdf
!bug1963407.pdf

BIN
test/pdfs/bug1963407.pdf Executable file

Binary file not shown.

View File

@ -12093,5 +12093,19 @@
"md5": "98b19e944339c01c10c503685eee3ad2",
"rounds": 1,
"type": "eq"
},
{
"id": "bug1963407",
"file": "pdfs/bug1963407.pdf",
"md5": "49d3d2dd42014d978af6e6ad814e5e64",
"rounds": 1,
"type": "eq",
"save": true,
"print": true,
"annotationStorage": {
"24R": {
"value": "Hello World"
}
}
}
]

View File

@ -2257,7 +2257,7 @@ describe("annotation", function () {
);
expect(newData.data).toEqual(
"2 0 obj\n<< /Subtype /Form /Resources " +
"<< /Font << /Helv 314 0 R>>>> /BBox [0 0 32 10] /Matrix [0 1 -1 0 32 0] /Length 74>> stream\n" +
"<< /Font << /Helv 314 0 R>>>> /BBox [0 0 10 32] /Matrix [0 1 -1 0 32 0] /Length 74>> stream\n" +
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2 2.94 Td (hello world) Tj " +
"ET Q EMC\nendstream\nendobj\n"
);
@ -3808,7 +3808,7 @@ describe("annotation", function () {
[
"2 0 obj",
"<< /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " +
"/BBox [0 0 32 10] /Matrix [0 -1 1 0 0 10] /Length 170>> stream",
"/BBox [0 0 10 32] /Matrix [0 -1 1 0 0 10] /Length 170>> stream",
"/Tx BMC q",
"1 1 10 32 re W n",
"0.600006 0.756866 0.854904 rg",