V3.3.0 — Edition contenu, actions CLI, menu contextuel enrichi

- Edition de contenu PDF (Annotations > Editer le contenu) :
  - Onglet Texte : liste le texte detecte, masquer des lignes
  - Onglet Images : liste les images, remplacer ou masquer
- Actions en ligne de commande (--action booklet_a4|booklet_a3|nup_2x2|unbooklet)
- Menu contextuel Windows enrichi :
  - Ouvrir, Livret A4, Livret A3, 2x2 par feuille, Delivretiser
- Bouton Editer dans la barre d'outils droite

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jules
2026-03-21 16:33:43 +01:00
parent 202a4fc536
commit 2fcc92dbd9
7 changed files with 324 additions and 7 deletions

50
main.py
View File

@@ -207,24 +207,64 @@ def main():
from app.main_window import MainWindow
window = MainWindow()
# Ouvrir les fichiers passes en argument
files_to_open = [a for a in sys.argv[1:] if a.lower().endswith('.pdf') and os.path.exists(a)]
# Gestion des arguments
args = sys.argv[1:]
action = None
files_to_open = []
i = 0
while i < len(args):
if args[i] == "--action" and i + 1 < len(args):
action = args[i + 1]
i += 2
elif args[i].lower().endswith('.pdf') and os.path.exists(args[i]):
files_to_open.append(args[i])
i += 1
else:
i += 1
if len(files_to_open) == 1:
window._open_pdf(files_to_open[0])
elif len(files_to_open) > 1:
# Plusieurs fichiers = fusionner
from pypdf import PdfWriter
import tempfile
import tempfile as tf
writer = PdfWriter()
for f in files_to_open:
writer.append(f)
fd, merged = tempfile.mkstemp(suffix=".pdf")
fd, merged = tf.mkstemp(suffix=".pdf")
os.close(fd)
with open(merged, "wb") as out:
writer.write(out)
window._open_pdf(merged)
window._status_label.setText(f"{len(files_to_open)} fichiers fusionnes")
# Actions en ligne de commande
if action and files_to_open:
from PyQt6.QtCore import QTimer
def run_cli_action():
from app.engine.booklet import create_booklet
from app.engine.nup import nup_pages
from app.engine.unbooklet import unbooklet
import tempfile as tf
fd, output = tf.mkstemp(suffix=".pdf")
os.close(fd)
src = files_to_open[0]
try:
if action == "booklet_a4":
create_booklet(src, output, binding="saddle_stitch", sheet_size=(841.89, 595.28))
elif action == "booklet_a3":
create_booklet(src, output, binding="saddle_stitch", sheet_size=(1190.55, 841.89))
elif action == "nup_2x2":
nup_pages(src, output, cols=2, rows=2, sheet_size=(841.89, 595.28))
elif action == "unbooklet":
unbooklet(src, output)
else:
return
window._show_result(output)
window._status_label.setText(f"Action '{action}' executee")
except Exception as e:
QMessageBox.critical(window, "Erreur", str(e))
QTimer.singleShot(500, run_cli_action)
window.show()
splash.close()
sys.exit(app.exec())