Initial commit — Copydev Imposing Tool

Outil d'imposition PDF desktop (PyQt6) remplacant Quite Imposing Plus.
9 fonctions : livret, n-up, step & repeat, imposition manuelle,
jointure pages, pages blanches, numerotation, masquage, fonds perdus.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jules
2026-03-20 10:54:02 +01:00
commit e3dfd90933
30 changed files with 2364 additions and 0 deletions

60
app/engine/join_pages.py Normal file
View File

@@ -0,0 +1,60 @@
"""Moteur Joindre deux pages."""
from pypdf import PdfReader, PdfWriter, PageObject, Transformation
from .pdf_utils import get_page_size
def join_pages(input_path, output_path, direction="horizontal"):
"""Joindre les pages par paires.
direction: "horizontal" (cote a cote) ou "vertical" (dessus/dessous)
"""
reader = PdfReader(input_path)
pages = reader.pages
writer = PdfWriter()
for i in range(0, len(pages), 2):
page1 = pages[i]
page2 = pages[i + 1] if i + 1 < len(pages) else None
w1, h1 = get_page_size(page1)
if page2:
w2, h2 = get_page_size(page2)
else:
w2, h2 = w1, h1
if direction == "horizontal":
new_w = w1 + w2
new_h = max(h1, h2)
sheet = PageObject.create_blank_page(width=new_w, height=new_h)
overlay1 = PageObject.create_blank_page(width=new_w, height=new_h)
overlay1.merge_page(page1)
sheet.merge_page(overlay1)
if page2:
overlay2 = PageObject.create_blank_page(width=new_w, height=new_h)
overlay2.merge_page(page2)
overlay2.add_transformation(Transformation().translate(w1, 0))
sheet.merge_page(overlay2)
else: # vertical
new_w = max(w1, w2)
new_h = h1 + h2
sheet = PageObject.create_blank_page(width=new_w, height=new_h)
overlay1 = PageObject.create_blank_page(width=new_w, height=new_h)
overlay1.merge_page(page1)
overlay1.add_transformation(Transformation().translate(0, h2))
sheet.merge_page(overlay1)
if page2:
overlay2 = PageObject.create_blank_page(width=new_w, height=new_h)
overlay2.merge_page(page2)
sheet.merge_page(overlay2)
writer.add_page(sheet)
with open(output_path, "wb") as f:
writer.write(f)
return output_path