Merge pull request #8964 from colinux/pdf-no-unbreakable

ETQ Utilisateur, je ne veux pas de caractère invalide dans l'état du dossier en PDF
This commit is contained in:
Colin Darie 2023-04-25 22:29:47 +00:00 committed by GitHub
commit 02fab28ad6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,10 @@ def maybe_start_new_page(pdf, size)
end
end
def clean_string(str)
str.tr(' ', ' ') # replace non breaking space, which are invalid in pdf
end
def text_box(pdf, text, x, width)
box = ::Prawn::Text::Box.new(text.to_s,
document: pdf,
@ -158,7 +162,7 @@ def add_single_champ(pdf, champ)
pdf.indent(default_margin) do
champ.geo_areas.each do |area|
pdf.text "- #{area.label}".tr(' ', ' ') # replace non breaking space, which are invalid in pdf
pdf.text "- #{clean_string(area.label)}"
end
end
end
@ -219,7 +223,7 @@ end
def add_etat_dossier(pdf, dossier)
pdf.pad_bottom(default_margin) do
pdf.text "Ce dossier est <b>#{dossier_display_state(dossier, lower: true)}</b>.", inline_format: true
pdf.text "Ce dossier est <b>#{clean_string(dossier_display_state(dossier, lower: true))}</b>.", inline_format: true
end
end