adjust font size if long text

This commit is contained in:
DocuSeal authored and Pete Matsyburka committed 2023-11-07 11:47:26 +02:00
1 parent a42ae0b39e
commit fc11078cae
4 files changed
+54 -5

No files matched your search

@@ -157,6 +157,17 @@ module Submissions
lines = layouter.fit([text], area['w'] * width, height).lines
box_height = lines.sum(&:height)
if box_height > (area['h'] * height) + 1
text = HexaPDF::Layout::TextFragment.create(Array.wrap(value).join(', '),
font: pdf.fonts.add(FONT_NAME),
font_size: (font_size / 1.4).to_i)
lines = layouter.fit([text], area['w'] * width, height).lines
box_height = lines.sum(&:height)
end
height_diff = [0, box_height - (area['h'] * height)].max
layouter.fit([text], area['w'] * width, height_diff.positive? ? box_height : area['h'] * height)