add cell field type

This commit is contained in:
Alex Turchyn
2023-06-27 00:57:29 +03:00
parent 419ede5b1d
commit 897df83633
14 changed files with 188 additions and 47 deletions
@@ -19,6 +19,8 @@ module Submissions
# rubocop:disable Metrics
def call(submitter)
layouter = HexaPDF::Layout::TextLayouter.new(valign: :center)
cell_layouter = HexaPDF::Layout::TextLayouter.new(valign: :center, align: :center)
template = submitter.submission.template
cert = submitter.submission.template.account.encrypted_configs
@@ -129,6 +131,17 @@ module Submissions
width: PdfIcons::WIDTH * scale,
height: PdfIcons::HEIGHT * scale
)
when 'cells'
cell_width = area['cell_w'] * width
value.chars.each_with_index do |char, index|
text = HexaPDF::Layout::TextFragment.create(char, font: pdf.fonts.add(FONT_NAME),
font_size: FONT_SIZE)
cell_layouter.fit([text], cell_width, area['h'] * height)
.draw(canvas, ((area['x'] * width) + (cell_width * index)),
height - (area['y'] * height))
end
else
value = I18n.l(Date.parse(value)) if field['type'] == 'date'