Skip to content

Commit df829ba

Browse files
authored
Merge pull request #393 from noctis0430-open-source/Issue/389
Fix #389
2 parents a65b38d + 8b5fa7b commit df829ba

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

PdfSharpCore/Pdf.Advanced/PdfFormXObject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ internal PdfFormXObject(PdfDocument thisDocument, PdfImportedObjectTable importe
212212

213213
// Translate the image such that its center lies on the center of the rotated bounding box
214214
double offset = (height - width) / 2;
215-
if (height > width)
215+
if (rotate == 90)
216216
matrix.TranslatePrepend(offset, offset);
217-
else
217+
else if (rotate == -90)
218218
matrix.TranslatePrepend(-offset, -offset);
219219

220220
//string item = "[" + PdfEncoders.ToString(matrix) + "]";

PdfSharpCore/Pdf/PdfPage.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ internal PdfPage(PdfDictionary dict)
7272
{
7373
// Set Orientation depending on /Rotate.
7474
int rotate = Elements.GetInteger(InheritablePageKeys.Rotate);
75-
var mediaBox = Elements.GetArray(InheritablePageKeys.MediaBox);
76-
if (Math.Abs((rotate / 90)) % 2 == 1 && mediaBox.Elements.GetReal(3) > mediaBox.Elements.GetReal(2))
75+
if (Math.Abs((rotate / 90)) % 2 == 1)
7776
_orientation = PageOrientation.Landscape;
7877
}
7978

0 commit comments

Comments
 (0)