set field alignment from PDF form field preferences
This commit is contained in:
committed by
Pete Matsyburka
parent
32596d738c
commit
f69dcf77de
@@ -63,6 +63,12 @@ module HexaPDF
|
|||||||
# rubocop:enable Rails/Blank
|
# rubocop:enable Rails/Blank
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class AppearanceGenerator
|
||||||
|
def create_push_button_appearances
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# comparison of Integer with HexaPDF::PDFArray failed
|
# comparison of Integer with HexaPDF::PDFArray failed
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ module Templates
|
|||||||
Selecionar |
|
Selecionar |
|
||||||
Escolher
|
Escolher
|
||||||
)\b/ix
|
)\b/ix
|
||||||
|
FIELD_ALIGNMENT = {
|
||||||
|
0 => 'left',
|
||||||
|
1 => 'center',
|
||||||
|
2 => 'right'
|
||||||
|
}.freeze
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
@@ -33,6 +38,8 @@ module Templates
|
|||||||
areas = Array.wrap(field[:Kids] || field).filter_map do |child_field|
|
areas = Array.wrap(field[:Kids] || field).filter_map do |child_field|
|
||||||
page = annots_index[child_field.hash]
|
page = annots_index[child_field.hash]
|
||||||
|
|
||||||
|
next unless page
|
||||||
|
|
||||||
media_box = page[:CropBox] || page[:MediaBox]
|
media_box = page[:CropBox] || page[:MediaBox]
|
||||||
crop_box = page[:CropBox] || media_box
|
crop_box = page[:CropBox] || media_box
|
||||||
|
|
||||||
@@ -124,6 +131,11 @@ module Templates
|
|||||||
field[:TU] != field.full_field_name &&
|
field[:TU] != field.full_field_name &&
|
||||||
!field[:TU].in?(SKIP_FIELD_DESCRIPTION)
|
!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?
|
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_index = (field.allowed_values || []).find_index(field.field_value)
|
||||||
selected_option = field[:Opt][selected_option_index] if selected_option_index
|
selected_option = field[:Opt][selected_option_index] if selected_option_index
|
||||||
|
|||||||
Reference in New Issue
Block a user