|
|
|
@ -70,6 +70,9 @@ def create_pdf_from_results(results, output_path): |
|
|
|
doc = SimpleDocTemplate(output_path, pagesize=letter, topMargin=inch, bottomMargin=inch) |
|
|
|
doc = SimpleDocTemplate(output_path, pagesize=letter, topMargin=inch, bottomMargin=inch) |
|
|
|
story = [] |
|
|
|
story = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Enregistre une police qui supporte le cyrilique |
|
|
|
|
|
|
|
font_name = register_unicode_font() |
|
|
|
|
|
|
|
|
|
|
|
# Style personnalisé |
|
|
|
# Style personnalisé |
|
|
|
styles = getSampleStyleSheet() |
|
|
|
styles = getSampleStyleSheet() |
|
|
|
title_style = ParagraphStyle( |
|
|
|
title_style = ParagraphStyle( |
|
|
|
@ -78,7 +81,8 @@ def create_pdf_from_results(results, output_path): |
|
|
|
fontSize=16, |
|
|
|
fontSize=16, |
|
|
|
textColor='#1f4788', |
|
|
|
textColor='#1f4788', |
|
|
|
spaceAfter=0.3*inch, |
|
|
|
spaceAfter=0.3*inch, |
|
|
|
alignment=TA_JUSTIFY |
|
|
|
alignment=TA_JUSTIFY, |
|
|
|
|
|
|
|
fontName=font_name |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
page_style = ParagraphStyle( |
|
|
|
page_style = ParagraphStyle( |
|
|
|
@ -87,7 +91,8 @@ def create_pdf_from_results(results, output_path): |
|
|
|
fontSize=12, |
|
|
|
fontSize=12, |
|
|
|
textColor='#1f4788', |
|
|
|
textColor='#1f4788', |
|
|
|
spaceAfter=0.2*inch, |
|
|
|
spaceAfter=0.2*inch, |
|
|
|
spaceBefore=0.2*inch |
|
|
|
spaceBefore=0.2*inch, |
|
|
|
|
|
|
|
fontName=font_name |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
body_style = ParagraphStyle( |
|
|
|
body_style = ParagraphStyle( |
|
|
|
@ -95,7 +100,8 @@ def create_pdf_from_results(results, output_path): |
|
|
|
parent=styles['BodyText'], |
|
|
|
parent=styles['BodyText'], |
|
|
|
fontSize=11, |
|
|
|
fontSize=11, |
|
|
|
alignment=TA_JUSTIFY, |
|
|
|
alignment=TA_JUSTIFY, |
|
|
|
spaceAfter=0.2*inch |
|
|
|
spaceAfter=0.2*inch, |
|
|
|
|
|
|
|
fontName=font_name |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# Titre |
|
|
|
# Titre |
|
|
|
@ -123,7 +129,7 @@ def main(): |
|
|
|
|
|
|
|
|
|
|
|
# Traitement page par page |
|
|
|
# Traitement page par page |
|
|
|
for i, page_text in enumerate(pages, start=1): |
|
|
|
for i, page_text in enumerate(pages, start=1): |
|
|
|
if( i > 3) : # Limite le nombre de pages pour les tests |
|
|
|
if( i > 2) : # Limite le nombre de pages pour les tests |
|
|
|
break |
|
|
|
break |
|
|
|
print(f"{15 * '-'} Traduction de la page {i}/{len(pages)}...") |
|
|
|
print(f"{15 * '-'} Traduction de la page {i}/{len(pages)}...") |
|
|
|
prompt = f"Traduis le texte suivant de l'ukrainien vers le français : {page_text}" |
|
|
|
prompt = f"Traduis le texte suivant de l'ukrainien vers le français : {page_text}" |
|
|
|
|