add text valign
This commit is contained in:
@@ -229,8 +229,9 @@ module Submissions
|
||||
text_align = field.dig('preferences', 'align').to_s.to_sym.presence ||
|
||||
(value.to_s.match?(RTL_REGEXP) ? :right : :left)
|
||||
|
||||
layouter = HexaPDF::Layout::TextLayouter.new(text_valign: :center, text_align:,
|
||||
font:, font_size:)
|
||||
text_valign = (field.dig('preferences', 'valign').to_s.presence || 'center').to_sym
|
||||
|
||||
layouter = HexaPDF::Layout::TextLayouter.new(text_valign:, text_align:, font:, font_size:)
|
||||
|
||||
next if Array.wrap(value).compact_blank.blank?
|
||||
|
||||
@@ -515,10 +516,19 @@ module Submissions
|
||||
0
|
||||
end
|
||||
|
||||
align_y_diff =
|
||||
if text_valign == :top
|
||||
0
|
||||
elsif text_valign == :bottom
|
||||
height_diff + TEXT_TOP_MARGIN
|
||||
else
|
||||
height_diff / 2
|
||||
end
|
||||
|
||||
layouter.fit([text], field['type'].in?(%w[date number]) ? width : area['w'] * width,
|
||||
height_diff.positive? ? box_height : area['h'] * height)
|
||||
.draw(canvas, (area['x'] * width) - right_align_x_adjustment + TEXT_LEFT_MARGIN,
|
||||
height - (area['y'] * height) + height_diff - TEXT_TOP_MARGIN)
|
||||
height - (area['y'] * height) + align_y_diff - TEXT_TOP_MARGIN)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user