From 16903376998e71ee2f9787412b3feca077d682d9 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Mon, 26 May 2025 10:11:01 +0300 Subject: [PATCH] fix pdf image result --- lib/submissions/generate_result_attachments.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/submissions/generate_result_attachments.rb b/lib/submissions/generate_result_attachments.rb index 5d697082..e260192d 100644 --- a/lib/submissions/generate_result_attachments.rb +++ b/lib/submissions/generate_result_attachments.rb @@ -735,14 +735,16 @@ module Submissions page = pdf.pages.add - scale = [A4_SIZE.first / attachment.metadata['width'].to_f, - A4_SIZE.last / attachment.metadata['height'].to_f].min + image = attachment.preview_images.first - page.box.width = attachment.metadata['width'] * scale - page.box.height = attachment.metadata['height'] * scale + scale = [A4_SIZE.first / image.metadata['width'].to_f, + A4_SIZE.last / image.metadata['height'].to_f].min + + page.box.width = image.metadata['width'] * scale + page.box.height = image.metadata['height'] * scale page.canvas.image( - StringIO.new(attachment.preview_images.first.download), + StringIO.new(image.download), at: [0, 0], width: page.box.width, height: page.box.height