1
0
forked from ScoDoc/ScoDoc

Améliore gestion font pdf manquant

This commit is contained in:
Emmanuel Viennet 2022-11-20 23:03:26 +01:00
parent a8b4ef2a22
commit 9dbcd2c8a2
4 changed files with 20 additions and 21 deletions

View File

@ -184,7 +184,7 @@ def process_field(field, cdict, style, suppress_empty_pars=False, format="pdf"):
# secure_filename dans la classe Logo
# log('field: %s' % (text))
return sco_pdf.makeParas(text, style, suppress_empty=suppress_empty_pars)
return sco_pdf.make_paras(text, style, suppress_empty=suppress_empty_pars)
def get_formsemestre_bulletins_pdf(formsemestre_id, version="selectedevals"):

View File

@ -49,11 +49,10 @@ Balises img: actuellement interdites.
from reportlab.platypus import KeepTogether, Paragraph, Spacer, Table
from reportlab.lib.units import cm, mm
from reportlab.lib.colors import Color, blue
from app.models import FormSemestre
from app.scodoc.sco_exceptions import ScoBugCatcher
import app.scodoc.sco_utils as scu
from app.scodoc.sco_pdf import SU
from app.scodoc.sco_pdf import SU, make_paras
from app.scodoc import sco_preferences
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_codes_parcours import (
@ -143,7 +142,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
)
else:
H.append("""<p class="bul_abs">Pas d'absences signalées.</p>""")
story.append(Paragraph(SU("Pas d'absences signalées."), self.CellStyle))
story += make_paras("Pas d'absences signalées.", self.CellStyle)
# ---- APPRECIATIONS
# le dir. des etud peut ajouter des appreciations,

View File

@ -117,7 +117,7 @@ def _splitPara(txt):
return L
def makeParas(txt, style, suppress_empty=False):
def make_paras(txt: str, style, suppress_empty=False) -> list[Paragraph]:
"""Returns a list of Paragraph instances from a text
with one or more <para> ... </para>
"""
@ -158,9 +158,9 @@ def makeParas(txt, style, suppress_empty=False):
style,
)
]
except ValueError as exc2: # probleme font ? essaye sans style
# recupere font en cause ?
m = re.match(r".*family/bold/italic for (.*)", e.args[0], re.DOTALL)
except ValueError: # probleme font ? essaye sans style
# récupère font en cause ?
m = re.match(r".*family/bold/italic for (.*)", exc.args[0], re.DOTALL)
if m:
message = f"police non disponible: {m[1]}"
else:

View File

@ -94,7 +94,7 @@ def page_footer(canvas, doc, logo, preferences, with_page_numbers=True):
right_foot_style.fontSize = preferences["SCOLAR_FONT_SIZE_FOOT"]
right_foot_style.alignment = TA_RIGHT
p = sco_pdf.makeParas(
p = sco_pdf.make_paras(
f"""<para>{preferences["INSTITUTION_NAME"]}</para><para>{
preferences["INSTITUTION_ADDRESS"]}</para>""",
left_foot_style,
@ -585,7 +585,7 @@ def pdf_lettre_individuelle(sem, decision, etud: Identite, params, signature=Non
or ""
) % params
sig = _simulate_br(sig, '<para leftindent="%(htab1)s">')
objects += sco_pdf.makeParas(
objects += sco_pdf.make_paras(
(
"""<para leftindent="%(htab1)s" spaceBefore="25mm">"""
+ sig
@ -602,7 +602,7 @@ def pdf_lettre_individuelle(sem, decision, etud: Identite, params, signature=Non
or ""
) % params
sig = _simulate_br(sig, '<para leftindent="%(htab1)s">')
objects += sco_pdf.makeParas(
objects += sco_pdf.make_paras(
(
"""<para leftindent="%(htab1)s" spaceBefore="25mm">"""
+ sig
@ -779,7 +779,7 @@ def _pvjury_pdf_type(
bulletStyle.spaceAfter = 5 * mm
objects += [Spacer(0, 5 * mm)]
objects += sco_pdf.makeParas(
objects += sco_pdf.make_paras(
"""
<para align="center"><b>Procès-verbal de %s du département %s - Session unique %s</b></para>
"""
@ -791,7 +791,7 @@ def _pvjury_pdf_type(
style,
)
objects += sco_pdf.makeParas(
objects += sco_pdf.make_paras(
"""
<para align="center"><b><i>%s</i></b></para>
"""
@ -800,20 +800,20 @@ def _pvjury_pdf_type(
)
if showTitle:
objects += sco_pdf.makeParas(
objects += sco_pdf.make_paras(
"""<para align="center"><b>Semestre: %s</b></para>""" % sem["titre"], style
)
if sco_preferences.get_preference("PV_TITLE_WITH_VDI", formsemestre_id):
objects += sco_pdf.makeParas(
objects += sco_pdf.make_paras(
"""<para align="center">VDI et Code: %s</para>""" % (VDICode or ""), style
)
if date_jury:
objects += sco_pdf.makeParas(
objects += sco_pdf.make_paras(
"""<para align="center">Jury tenu le %s</para>""" % date_jury, style
)
objects += sco_pdf.makeParas(
objects += sco_pdf.make_paras(
"<para>"
+ (sco_preferences.get_preference("PV_INTRO", formsemestre_id) or "")
% {
@ -828,7 +828,7 @@ def _pvjury_pdf_type(
bulletStyle,
)
objects += sco_pdf.makeParas(
objects += sco_pdf.make_paras(
"""<para>Le jury propose les décisions suivantes :</para>""", style
)
objects += [Spacer(0, 4 * mm)]
@ -881,7 +881,7 @@ def _pvjury_pdf_type(
objects.append(Table(Pt, repeatRows=1, colWidths=widths, style=table_style))
# Signature du directeur
objects += sco_pdf.makeParas(
objects += sco_pdf.make_paras(
"""<para spaceBefore="10mm" align="right">
%s, %s</para>"""
% (
@ -894,7 +894,7 @@ def _pvjury_pdf_type(
# Légende des codes
codes = list(sco_codes_parcours.CODES_EXPL.keys())
codes.sort()
objects += sco_pdf.makeParas(
objects += sco_pdf.make_paras(
"""<para spaceBefore="15mm" fontSize="14">
<b>Codes utilisés :</b></para>""",
style,