diff --git a/modules/representation_management/lib/fonts/bitter-bold.ttf b/modules/representation_management/lib/fonts/bitter-bold.ttf new file mode 100644 index 00000000000..c18692f0a01 Binary files /dev/null and b/modules/representation_management/lib/fonts/bitter-bold.ttf differ diff --git a/modules/representation_management/lib/fonts/bitter-regular.ttf b/modules/representation_management/lib/fonts/bitter-regular.ttf new file mode 100644 index 00000000000..b6a610deac8 Binary files /dev/null and b/modules/representation_management/lib/fonts/bitter-regular.ttf differ diff --git a/modules/representation_management/lib/fonts/sourcesanspro-regular-webfont.ttf b/modules/representation_management/lib/fonts/sourcesanspro-regular-webfont.ttf new file mode 100644 index 00000000000..ac42fa1c241 Binary files /dev/null and b/modules/representation_management/lib/fonts/sourcesanspro-regular-webfont.ttf differ diff --git a/modules/representation_management/lib/representation_management/v0/pdf_constructor/base.rb b/modules/representation_management/lib/representation_management/v0/pdf_constructor/base.rb index 1b80a793a23..d6035084d94 100644 --- a/modules/representation_management/lib/representation_management/v0/pdf_constructor/base.rb +++ b/modules/representation_management/lib/representation_management/v0/pdf_constructor/base.rb @@ -55,22 +55,16 @@ def next_steps_contact(_pdf, _data) end def next_steps_part1(pdf) - pdf.font_size(20) - pdf.text('Fill out your form to appoint a VA accredited representative or VSO') - pdf.move_down(10) - pdf.font_size(12) - pdf.text('VA Form 21-22a') - pdf.move_down(10) - pdf.font_size(16) - pdf.text('Your Next Steps') - pdf.move_down(10) - pdf.font_size(12) + add_text_with_spacing(pdf, + 'Request help from a VA accredited representative or VSO', size: 20, + style: :bold) + add_text_with_spacing(pdf, 'VA Form 21-22a') + add_text_with_spacing(pdf, 'Your Next Steps', size: 16, style: :bold) str = <<~HEREDOC.squish Both you and the accredited representative will need to sign your form. You can bring your form to them in person or mail it to them. HEREDOC - pdf.text(str) - pdf.move_down(30) + add_text_with_spacing(pdf, str, move_down: 30, font: 'soursesanspro') end def next_steps_part2(pdf) @@ -79,37 +73,59 @@ def next_steps_part2(pdf) After your form is signed, you or the accredited representative can submit it online, by mail, or in person. HEREDOC - pdf.text(str) - pdf.move_down(10) - pdf.font_size(16) - pdf.text('After you submit your printed form') - pdf.move_down(10) - pdf.font_size(12) - str = <<~HEREDOC.squish - We'll confirm that the accredited representative is available to help you. - Then we'll update your VA.gov profile with their information. - HEREDOC - pdf.text(str) - pdf.move_down(10) + add_text_with_spacing(pdf, str, font: 'soursesanspro') + add_text_with_spacing(pdf, 'After you submit your printed form', size: 16, style: :bold) end def next_steps_part3(pdf) str = <<~HEREDOC.squish - We usually process your form within 1 week. - You can contact the accredited representative any time to ask when they can start helping you. + We usually process your form within 1 week. You can contact the accredited representative any time. HEREDOC - pdf.text(str) - pdf.move_down(10) - pdf.font_size(14) - pdf.text('Need help?') - pdf.move_down(10) - pdf.font_size(12) - pdf.text("You can call us at 800-698-2411, ext. 0 (TTY: 711). We're here 24/7.") - pdf.move_down(10) + add_text_with_spacing(pdf, str, font: 'soursesanspro') + add_text_with_spacing(pdf, 'Need help?', size: 14, style: :bold) + add_text_with_spacing(pdf, "You can call us at 800-698-2411, ext. 0 (TTY: 711). We're here 24/7.", + font: 'soursesanspro') end private + # Adds text to the PDF with specified spacing and formatting options. + # + # @param pdf [PDF::Document] The PDF document to add the text to. + # @param text [String] The text to be added. + # @param options [Hash] (optional) The formatting options for the text. + # @option options [Integer] :size (12) The font size of the text. + # @option options [Integer] :move_down (10) The amount of vertical spacing to move down after adding the text. + # @option options [Symbol] :style (:normal) The font style of the text. + # @option options [String] :font ('bitter') The font family of the text. + # @return [void] + def add_text_with_spacing(pdf, text, options = {}) + size = options.fetch(:size, 12) + move_down = options.fetch(:move_down, 10) + style = options.fetch(:style, :normal) + font = options.fetch(:font, 'bitter') + + pdf.font(font, style:) do + pdf.font_size(size) + pdf.text(text) + pdf.move_down(move_down) + end + pdf.font_size(12) # Reset to default size + end + + # Formats a phone number by removing non-digit characters and adding dashes. + # + # @param phone_number [String] The phone number to be formatted. + # @return [String] The formatted phone number. + def format_phone_number(phone_number) + return '' if phone_number.blank? + + phone_number = phone_number.gsub(/\D/, '') + return phone_number if phone_number.length < 10 + + "#{phone_number[0..2]}-#{phone_number[3..5]}-#{phone_number[6..9]}" + end + # # Fill in pdf form fields based on data provided, then combine all # the pages into a final pdf. We create an inner tempfile to fill @@ -130,6 +146,16 @@ def fill_and_combine_pdf(data) def generate_next_steps_page(data) tempfile = Tempfile.new next_steps = Prawn::Document.new + next_steps.font_families.update( + 'bitter' => { + normal: Rails.root.join('modules', 'representation_management', 'lib', 'fonts', 'bitter-regular.ttf'), + bold: Rails.root.join('modules', 'representation_management', 'lib', 'fonts', 'bitter-bold.ttf') + }, + 'soursesanspro' => { + normal: Rails.root.join('modules', 'representation_management', 'lib', 'fonts', + 'sourcesanspro-regular-webfont.ttf') + } + ) next_steps_part1(next_steps) next_steps_contact(next_steps, data) next_steps_part2(next_steps) diff --git a/modules/representation_management/lib/representation_management/v0/pdf_constructor/form_2122a.rb b/modules/representation_management/lib/representation_management/v0/pdf_constructor/form_2122a.rb index bdfeed70a48..6a3a715b4cd 100644 --- a/modules/representation_management/lib/representation_management/v0/pdf_constructor/form_2122a.rb +++ b/modules/representation_management/lib/representation_management/v0/pdf_constructor/form_2122a.rb @@ -20,18 +20,20 @@ def next_steps_contact(pdf, data) #{data.representative_middle_initial} #{data.representative_last_name} HEREDOC - pdf.text(rep_name) - pdf.text(data.representative_address_line1) - pdf.text(data.representative_address_line2) - city_state_zip = <<~HEREDOC.squish - #{data.representative_city}, - #{data.representative_state_code} - #{data.representative_zip_code} - HEREDOC - pdf.text(city_state_zip) - pdf.move_down(5) - pdf.text(data.representative_phone) - pdf.text(data.representative_email_address) + add_text_with_spacing(pdf, rep_name, style: :bold, move_down: 8) + pdf.font('soursesanspro') do + pdf.text(data.representative_address_line1) + pdf.text(data.representative_address_line2) + city_state_zip = <<~HEREDOC.squish + #{data.representative_city}, + #{data.representative_state_code} + #{data.representative_zip_code} + HEREDOC + pdf.text(city_state_zip) + pdf.move_down(5) + pdf.text(format_phone_number(data.representative_phone)) + pdf.text(data.representative_email_address) + end end def template_path diff --git a/modules/representation_management/spec/fixtures/21-22A/v0/2122a_conditions_and_limitations.pdf b/modules/representation_management/spec/fixtures/21-22A/v0/2122a_conditions_and_limitations.pdf index 81115c86a6e..1c585f7eb32 100644 Binary files a/modules/representation_management/spec/fixtures/21-22A/v0/2122a_conditions_and_limitations.pdf and b/modules/representation_management/spec/fixtures/21-22A/v0/2122a_conditions_and_limitations.pdf differ diff --git a/modules/representation_management/spec/fixtures/21-22A/v0/2122a_conditions_and_limitations_no_claimant.pdf b/modules/representation_management/spec/fixtures/21-22A/v0/2122a_conditions_and_limitations_no_claimant.pdf index 431f2be7793..018495dc07b 100644 Binary files a/modules/representation_management/spec/fixtures/21-22A/v0/2122a_conditions_and_limitations_no_claimant.pdf and b/modules/representation_management/spec/fixtures/21-22A/v0/2122a_conditions_and_limitations_no_claimant.pdf differ