set field alignment from PDF form field preferences

pull/414/head
Alex Turchyn 10 months ago committed by Pete Matsyburka
parent 32596d738c
commit f69dcf77de

@ -63,6 +63,12 @@ module HexaPDF
# rubocop:enable Rails/Blank
end
end
class AppearanceGenerator
def create_push_button_appearances
nil
end
end
end
# comparison of Integer with HexaPDF::PDFArray failed

@ -20,6 +20,11 @@ module Templates
Selecionar |
Escolher
)\b/ix
FIELD_ALIGNMENT = {
0 => 'left',
1 => 'center',
2 => 'right'
}.freeze
module_function
@ -33,6 +38,8 @@ module Templates
areas = Array.wrap(field[:Kids] || field).filter_map do |child_field|
page = annots_index[child_field.hash]
next unless page
media_box = page[:CropBox] || page[:MediaBox]
crop_box = page[:CropBox] || media_box
@ -124,6 +131,11 @@ module Templates
field[:TU] != field.full_field_name &&
!field[:TU].in?(SKIP_FIELD_DESCRIPTION)
if field[:Q].present? && field.field_type == :Tx
attrs[:preferences] ||= {}
attrs[:preferences][:align] = FIELD_ALIGNMENT.fetch(field[:Q], 'left')
end
if field.field_type == :Btn && field.concrete_field_type == :radio_button && field[:Opt].present?
selected_option_index = (field.allowed_values || []).find_index(field.field_value)
selected_option = field[:Opt][selected_option_index] if selected_option_index

Loading…
Cancel
Save