|
|
|
@ -321,9 +321,9 @@ module Submissions
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
reason_text = HexaPDF::Layout::TextFragment.create(reason_string,
|
|
|
|
base_font_size = (font_size / 1.8).to_i
|
|
|
|
font:,
|
|
|
|
|
|
|
|
font_size: (font_size / 1.8).to_i)
|
|
|
|
result = nil
|
|
|
|
|
|
|
|
|
|
|
|
if area['h']&.positive? && (area['w'].to_f / area['h']) > 6
|
|
|
|
if area['h']&.positive? && (area['w'].to_f / area['h']) > 6
|
|
|
|
area_x = area['x'] * width
|
|
|
|
area_x = area['x'] * width
|
|
|
|
@ -344,12 +344,10 @@ module Submissions
|
|
|
|
|
|
|
|
|
|
|
|
id_string = "ID: #{attachment.uuid}".upcase
|
|
|
|
id_string = "ID: #{attachment.uuid}".upcase
|
|
|
|
|
|
|
|
|
|
|
|
while true
|
|
|
|
loop do
|
|
|
|
text = HexaPDF::Layout::TextFragment.create(id_string,
|
|
|
|
text = HexaPDF::Layout::TextFragment.create(id_string, font:, font_size: base_font_size)
|
|
|
|
font:,
|
|
|
|
|
|
|
|
font_size: (font_size / 1.8).to_i)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = layouter.fit([text], half_width, (font_size / 1.8) / 0.65)
|
|
|
|
result = layouter.fit([text], half_width, base_font_size / 0.65)
|
|
|
|
|
|
|
|
|
|
|
|
break if result.status == :success
|
|
|
|
break if result.status == :success
|
|
|
|
|
|
|
|
|
|
|
|
@ -358,25 +356,39 @@ module Submissions
|
|
|
|
break if id_string.length < 8
|
|
|
|
break if id_string.length < 8
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
text_x = area_x + half_width
|
|
|
|
string = [id_string, reason_string].join("\n")
|
|
|
|
text_y = height - area_y
|
|
|
|
|
|
|
|
|
|
|
|
loop do
|
|
|
|
|
|
|
|
text = HexaPDF::Layout::TextFragment.create(string, font:, font_size: base_font_size)
|
|
|
|
|
|
|
|
|
|
|
|
reason_result = layouter.fit([reason_text], half_width, height)
|
|
|
|
result = layouter.fit([text], half_width, area_h)
|
|
|
|
|
|
|
|
|
|
|
|
layouter.fit([text], half_width, (font_size / 1.8) / 0.65)
|
|
|
|
break if result.status == :success
|
|
|
|
.draw(canvas, text_x + TEXT_LEFT_MARGIN, text_y)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layouter.fit([reason_text], half_width, reason_result.lines.sum(&:height))
|
|
|
|
base_font_size *= 0.9
|
|
|
|
.draw(canvas, text_x + TEXT_LEFT_MARGIN, text_y - TEXT_TOP_MARGIN - result.lines.sum(&:height))
|
|
|
|
|
|
|
|
|
|
|
|
break if base_font_size < 2
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
text = HexaPDF::Layout::TextFragment.create(string, font:, font_size: base_font_size)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
text_x = area_x + half_width
|
|
|
|
|
|
|
|
text_y = height - area_y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layouter.fit([text], half_width, area_h).draw(canvas, text_x + TEXT_LEFT_MARGIN, text_y)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
reason_text = HexaPDF::Layout::TextFragment.create(reason_string,
|
|
|
|
|
|
|
|
font:,
|
|
|
|
|
|
|
|
font_size: base_font_size)
|
|
|
|
|
|
|
|
|
|
|
|
id_string = "ID: #{attachment.uuid}".upcase
|
|
|
|
id_string = "ID: #{attachment.uuid}".upcase
|
|
|
|
|
|
|
|
|
|
|
|
loop do
|
|
|
|
loop do
|
|
|
|
text = HexaPDF::Layout::TextFragment.create(id_string,
|
|
|
|
text = HexaPDF::Layout::TextFragment.create(id_string,
|
|
|
|
font:,
|
|
|
|
font:,
|
|
|
|
font_size: (font_size / 1.8).to_i)
|
|
|
|
font_size: base_font_size)
|
|
|
|
|
|
|
|
|
|
|
|
result = layouter.fit([text], area['w'] * width, (font_size / 1.8) / 0.65)
|
|
|
|
result = layouter.fit([text], area['w'] * width, base_font_size / 0.65)
|
|
|
|
|
|
|
|
|
|
|
|
break if result.status == :success
|
|
|
|
break if result.status == :success
|
|
|
|
|
|
|
|
|
|
|
|
@ -395,7 +407,7 @@ module Submissions
|
|
|
|
|
|
|
|
|
|
|
|
io = StringIO.new(image.resize([scale * 4, 1].select(&:positive?).min).write_to_buffer('.png'))
|
|
|
|
io = StringIO.new(image.resize([scale * 4, 1].select(&:positive?).min).write_to_buffer('.png'))
|
|
|
|
|
|
|
|
|
|
|
|
layouter.fit([text], area['w'] * width, (font_size / 1.8) / 0.65)
|
|
|
|
layouter.fit([text], area['w'] * width, base_font_size / 0.65)
|
|
|
|
.draw(canvas, (area['x'] * width) + TEXT_LEFT_MARGIN,
|
|
|
|
.draw(canvas, (area['x'] * width) + TEXT_LEFT_MARGIN,
|
|
|
|
height - (area['y'] * height) - TEXT_TOP_MARGIN - image_height)
|
|
|
|
height - (area['y'] * height) - TEXT_TOP_MARGIN - image_height)
|
|
|
|
|
|
|
|
|
|
|
|
|