diff --git a/app/views/submissions/show.html.erb b/app/views/submissions/show.html.erb index 09d57646..fff9f56f 100644 --- a/app/views/submissions/show.html.erb +++ b/app/views/submissions/show.html.erb @@ -232,7 +232,7 @@ <% elsif field['type'] == 'date' %> <%= TimeUtils.format_date_string(value, field.dig('preferences', 'format'), @submission.account.locale) %> <% else %> - <%= Array.wrap(value).join(', ') %> +
<%= Array.wrap(value).join(', ') %>
<% end %> diff --git a/lib/submissions/generate_result_attachments.rb b/lib/submissions/generate_result_attachments.rb index 1686d7ec..a5941863 100644 --- a/lib/submissions/generate_result_attachments.rb +++ b/lib/submissions/generate_result_attachments.rb @@ -18,6 +18,8 @@ module Submissions TEXT_TOP_MARGIN = 1 MAX_PAGE_ROTATE = 20 + COURIER_FONT = 'Courier' + A4_SIZE = [595, 842].freeze TESTING_FOOTER = 'Testing Document - NOT LEGALLY BINDING' @@ -188,7 +190,8 @@ module Submissions fill_color = field.dig('preferences', 'color').presence - font = pdf.fonts.add(field.dig('preferences', 'font').presence || FONT_NAME) + font_name = field.dig('preferences', 'font').presence || FONT_NAME + font = pdf.fonts.add(font_name) value = submitter.values[field['uuid']] value = field['default_value'] if field['type'] == 'heading' @@ -435,18 +438,19 @@ module Submissions value = TextUtils.maybe_rtl_reverse(Array.wrap(value).join(', ')) - text = HexaPDF::Layout::TextFragment.create(value, font:, - fill_color:, - font_size:) + text_params = { font:, fill_color:, font_size: } + text_params[:line_height] = text_params[:font_size] * 1.6 if font_name == COURIER_FONT + + text = HexaPDF::Layout::TextFragment.create(value, **text_params) lines = layouter.fit([text], area['w'] * width, height).lines box_height = lines.sum(&:height) if preferences_font_size.blank? && box_height > (area['h'] * height) + 1 - text = HexaPDF::Layout::TextFragment.create(value, - font:, - fill_color:, - font_size: (font_size / 1.4).to_i) + text_params[:font_size] = (font_size / 1.4).to_i + text_params[:line_height] = text_params[:font_size] * 1.6 if font_name == COURIER_FONT + + text = HexaPDF::Layout::TextFragment.create(value, **text_params) lines = layouter.fit([text], field['type'].in?(%w[date number]) ? width : area['w'] * width, height).lines @@ -454,10 +458,10 @@ module Submissions end if preferences_font_size.blank? && box_height > (area['h'] * height) + 1 - text = HexaPDF::Layout::TextFragment.create(value, - font:, - fill_color:, - font_size: (font_size / 1.9).to_i) + text_params[:font_size] = (font_size / 1.9).to_i + text_params[:line_height] = text_params[:font_size] * 1.6 if font_name == COURIER_FONT + + text = HexaPDF::Layout::TextFragment.create(value, **text_params) lines = layouter.fit([text], field['type'].in?(%w[date number]) ? width : area['w'] * width, height).lines