fix(pdf): enlève des espaces insécables qui étaient affichés comme "?" dans le pdf

This commit is contained in:
Colin Darie 2023-08-31 17:03:34 +02:00
parent 680919a68f
commit 50a5e363bd
No known key found for this signature in database
GPG key ID: 8C76CADD40253590

View file

@ -11,7 +11,7 @@ def maybe_start_new_page(pdf, size)
end end
def clean_string(str) def clean_string(str)
str.tr(' ', ' ') # replace non breaking space, which are invalid in pdf str&.gsub(/[[:space:]]/, ' ') # replace non breaking space, which are invalid in pdf
end end
def text_box(pdf, text, x, width) def text_box(pdf, text, x, width)
@ -209,7 +209,7 @@ def add_message(pdf, message)
end end
format_in_2_lines(pdf, "#{sender}, #{try_format_date(message.created_at)}", format_in_2_lines(pdf, "#{sender}, #{try_format_date(message.created_at)}",
ActionView::Base.full_sanitizer.sanitize(message.body)) ActionView::Base.full_sanitizer.sanitize(clean_string(message.body)))
end end
def add_avis(pdf, avis) def add_avis(pdf, avis)
@ -276,7 +276,7 @@ prawn_document(page_size: "A4") do |pdf|
add_etat_dossier(pdf, @dossier) add_etat_dossier(pdf, @dossier)
if @dossier.motivation.present? if @dossier.motivation.present?
format_in_2_columns(pdf, "Motif de la décision", @dossier.motivation) format_in_2_columns(pdf, "Motif de la décision", clean_string(@dossier.motivation))
end end
add_title(pdf, 'Historique') add_title(pdf, 'Historique')
add_etats_dossier(pdf, @dossier) add_etats_dossier(pdf, @dossier)