Numéros pages sur bulletins BUT. Closes #652

This commit is contained in:
Emmanuel Viennet 2024-05-30 12:08:41 +02:00
parent 50f2cd7a0f
commit 9897ccc659
4 changed files with 11 additions and 7 deletions

View File

@ -226,6 +226,7 @@ class BulletinGenerator:
server_name=self.server_name,
filigranne=self.filigranne,
preferences=sco_preferences.SemPreferences(formsemestre_id),
with_page_numbers=self.multi_pages,
)
)
try:

View File

@ -106,6 +106,7 @@ def assemble_bulletins_pdf(
pagesbookmarks=pagesbookmarks,
filigranne=filigranne,
preferences=sco_preferences.SemPreferences(formsemestre_id),
with_page_numbers=False, # on ne veut pas de no de pages sur les bulletins imprimés en masse
)
)
document.multiBuild(story)

View File

@ -247,6 +247,7 @@ class ScoDocPageTemplate(PageTemplate):
footer_template=DEFAULT_PDF_FOOTER_TEMPLATE,
filigranne=None,
preferences=None, # dictionnary with preferences, required
with_page_numbers=False,
):
"""Initialise our page template."""
# defered import (solve circular dependency ->sco_logo ->scodoc, ->sco_pdf
@ -259,8 +260,9 @@ class ScoDocPageTemplate(PageTemplate):
self.pdfmeta_subject = subject
self.server_name = server_name
self.filigranne = filigranne
self.page_number = 1
self.footer_template = footer_template
self.with_page_numbers = with_page_numbers
self.page_number = 1
if self.preferences:
self.with_page_background = self.preferences["bul_pdf_with_background"]
else:
@ -337,6 +339,7 @@ class ScoDocPageTemplate(PageTemplate):
def draw_footer(self, canv, content):
"""Print the footer"""
# called 1/page
try:
canv.setFont(
self.preferences["SCOLAR_FONT"],
@ -353,6 +356,9 @@ class ScoDocPageTemplate(PageTemplate):
self.preferences["pdf_footer_y"] * mm,
content + " " + (self.preferences["pdf_footer_extra"] or ""),
)
if self.with_page_numbers:
canv.drawString(190.0 * mm, 6 * mm, f"Page {self.page_number}")
canv.restoreState()
def footer_string(self) -> str:
@ -389,11 +395,7 @@ class ScoDocPageTemplate(PageTemplate):
canv.drawCentredString(0, 0, SU(filigranne))
canv.restoreState()
doc.filigranne = None
def afterPage(self):
"""Called after all flowables have been drawn on a page.
Increment pageNum since the page has been completed.
"""
# Increment page number
self.page_number += 1

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.6.968"
SCOVERSION = "9.6.969"
SCONAME = "ScoDoc"