Skip to content

Commit

Permalink
Merge pull request #7148 from DFE-Digital/update-pdf-font
Browse files Browse the repository at this point in the history
Add Arial as PDF font for UTF encoding
  • Loading branch information
ddippolito authored Oct 7, 2024
2 parents 1d8de63 + d840372 commit eef32f4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
Binary file added app/assets/fonts/Arial-Unicode-Bold.ttf
Binary file not shown.
Binary file added app/assets/fonts/Arial-Unicode-Italic.ttf
Binary file not shown.
Binary file added app/assets/fonts/Arial-Unicode-Regular.ttf
Binary file not shown.
13 changes: 13 additions & 0 deletions app/helpers/pdf_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ module PdfHelper
include JobApplicationsHelper
include QualificationsHelper

# Arial Unicode is a font that supports all characters.
def update_font_family(pdf)
pdf.font_families.update(
"Arial Unicode" =>
{
bold: Rails.root.join("app/assets/fonts/Arial-Unicode-Bold.ttf").to_s,
normal: Rails.root.join("app/assets/fonts/Arial-Unicode-Regular.ttf").to_s,
italic: Rails.root.join("app/assets/fonts/Arial-Unicode-Italic.ttf").to_s,
},
)
pdf.font("Arial Unicode", encoding: "UTF-8")
end

def add_section_title(pdf, title)
pdf.move_down 20
pdf.text title, size: 18, style: :bold
Expand Down
1 change: 1 addition & 0 deletions app/services/job_application_pdf_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def initialize(job_application, vacancy)

def generate
Prawn::Document.new do |pdf|
update_font_family(pdf)
add_image_to_first_page(pdf)
add_headers(pdf)
pdf.stroke_horizontal_rule
Expand Down

0 comments on commit eef32f4

Please sign in to comment.