From 4e0fe9d9d0af1d4a64a92ae859d9f6f6d39e3be9 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 25 Feb 2024 09:43:38 -0500 Subject: [PATCH] MacPDF: Honor page rotation --- Meta/Lagom/Contrib/MacPDF/MacPDFView.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Meta/Lagom/Contrib/MacPDF/MacPDFView.mm b/Meta/Lagom/Contrib/MacPDF/MacPDFView.mm index 1c072a8214..268b2c1f00 100644 --- a/Meta/Lagom/Contrib/MacPDF/MacPDFView.mm +++ b/Meta/Lagom/Contrib/MacPDF/MacPDFView.mm @@ -24,9 +24,9 @@ static PDF::PDFErrorOr> render(PDF::Document& documen { auto page = TRY(document.get_page(page_index)); - Gfx::IntSize page_size; - page_size.set_width(size.width); - page_size.set_height(size.height); + auto page_size = Gfx::IntSize { size.width, size.height }; + if (int rotation_count = (page.rotate / 90) % 4; rotation_count % 2 == 1) + page_size = Gfx::IntSize { page_size.height(), page_size.width() }; auto bitmap = TRY(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, page_size)); @@ -36,7 +36,7 @@ static PDF::PDFErrorOr> render(PDF::Document& documen NSLog(@"warning: %@", @(error.message().characters())); } - return bitmap; + return TRY(PDF::Renderer::apply_page_rotation(bitmap, page)); } static NSBitmapImageRep* ns_from_gfx(NonnullRefPtr bitmap_p)