From 9897ccc65905311c499b9876eb65c22856f702c1 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 30 May 2024 12:08:41 +0200 Subject: [PATCH] =?UTF-8?q?Num=C3=A9ros=20pages=20sur=20bulletins=20BUT.?= =?UTF-8?q?=20Closes=20#652?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_bulletins_generator.py | 1 + app/scodoc/sco_bulletins_pdf.py | 1 + app/scodoc/sco_pdf.py | 14 ++++++++------ sco_version.py | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/scodoc/sco_bulletins_generator.py b/app/scodoc/sco_bulletins_generator.py index 4fbeb9820..efb785b92 100644 --- a/app/scodoc/sco_bulletins_generator.py +++ b/app/scodoc/sco_bulletins_generator.py @@ -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: diff --git a/app/scodoc/sco_bulletins_pdf.py b/app/scodoc/sco_bulletins_pdf.py index dddd4430e..678c7d96d 100644 --- a/app/scodoc/sco_bulletins_pdf.py +++ b/app/scodoc/sco_bulletins_pdf.py @@ -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) diff --git a/app/scodoc/sco_pdf.py b/app/scodoc/sco_pdf.py index 09bc143cd..6d5f72e2b 100755 --- a/app/scodoc/sco_pdf.py +++ b/app/scodoc/sco_pdf.py @@ -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 diff --git a/sco_version.py b/sco_version.py index 16534d3d1..ffcc3e8ad 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.6.968" +SCOVERSION = "9.6.969" SCONAME = "ScoDoc"