Skip to content

Commit 5d7bbf9

Browse files
Samuel HuylebroeckiText-CI
authored andcommitted
Normalize PdfArray#toRectangle
Will now return the rectangle defined by lower-left and upper-right corners instead of raw extractraction DEVSIX-2530 Autoported commit. Original commit hash: [badd958c6]
1 parent 7c612e2 commit 5d7bbf9

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

itext/itext.kernel/itext/kernel/pdf/PdfArray.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,16 @@ public virtual Rectangle ToRectangle() {
473473
float y1 = GetAsNumber(1).FloatValue();
474474
float x2 = GetAsNumber(2).FloatValue();
475475
float y2 = GetAsNumber(3).FloatValue();
476-
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
476+
float llx;
477+
float lly;
478+
float urx;
479+
float ury;
480+
//Find the lower-left and upper-right of these 4 points
481+
llx = Math.Min(x1, x2);
482+
lly = Math.Min(y1, y2);
483+
urx = Math.Max(x1, x2);
484+
ury = Math.Max(y1, y2);
485+
return new Rectangle(llx, lly, urx - llx, ury - lly);
477486
}
478487
catch (Exception e) {
479488
throw new PdfException(PdfException.CannotConvertPdfArrayToRectanle, e, this);

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0e5b707dd302e20955b3e0bb77782d9495171b89
1+
badd958c6688332e7e47b8f3d687e4a4377dfbc6

0 commit comments

Comments
 (0)