From fe2d4d85c429d972e17038c9e78795c2a2ead2ff Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Mon, 10 May 2021 14:06:16 -0700 Subject: [PATCH] PDFViewer: Add some padding to the outside of the page --- Userland/Applications/PDFViewer/PDFViewer.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Userland/Applications/PDFViewer/PDFViewer.cpp b/Userland/Applications/PDFViewer/PDFViewer.cpp index d2e018cb50a147..87902dc39f88b8 100644 --- a/Userland/Applications/PDFViewer/PDFViewer.cpp +++ b/Userland/Applications/PDFViewer/PDFViewer.cpp @@ -9,6 +9,8 @@ #include #include +static constexpr int PAGE_PADDING = 25; + PDFViewer::PDFViewer() { set_should_hide_unnecessary_scrollbars(true); @@ -130,12 +132,12 @@ RefPtr PDFViewer::render_page(const PDF::Page& page) { auto zoom_scale_factor = static_cast(zoom_levels[m_zoom_level]) / 100.0f; - float page_width = page.media_box.upper_right_x - page.media_box.lower_left_x; - float page_height = page.media_box.upper_right_y - page.media_box.lower_left_y; - float page_scale_factor = page_height / page_width; + auto page_width = page.media_box.upper_right_x - page.media_box.lower_left_x; + auto page_height = page.media_box.upper_right_y - page.media_box.lower_left_y; + auto page_scale_factor = page_height / page_width; - float width = 300.0f * zoom_scale_factor; - float height = width * page_scale_factor; + auto height = static_cast(this->height() - 2 * frame_thickness() - PAGE_PADDING * 2) * zoom_scale_factor; + auto width = height / page_scale_factor; auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { width, height }); PDF::Renderer::render(*m_document, page, bitmap);