Repository navigation
Expand file tree
/
Copy pathgenerate_pdf_professional.py
More file actions
539 lines (460 loc) · 15.8 KB
/
Copy pathgenerate_pdf_professional.py
File metadata and controls
539 lines (460 loc) · 15.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
#!/usr/bin/env python3
"""
Générateur PDF Professionnel pour ULC-ICAM Turnin System
"""
import os
import webbrowser
from pathlib import Path
def create_professional_html():
"""Crée une version HTML professionnelle optimisée"""
md_file = Path("presentation_detaillee.md")
if not md_file.exists():
print("❌ Fichier presentation_detaillee.md non trouvé")
return None
with open(md_file, 'r', encoding='utf-8') as f:
content = f.read()
html_content = convert_markdown_to_html(content)
html_template = f"""
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>ULC-ICAM Turnin System - Présentation Professionnelle</title>
<style>
@page {{
size: A4;
margin: 2.5cm;
}}
* {{
box-sizing: border-box;
}}
body {{
font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
line-height: 1.7;
color: #2c3e50;
font-size: 11pt;
margin: 0;
padding: 0;
background: #ffffff;
}}
.cover-page {{
text-align: center;
padding: 60px 40px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-radius: 15px;
margin-bottom: 40px;
page-break-after: always;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}}
.logo-container {{
margin: 30px 0;
}}
.logo {{
width: 120px;
height: 120px;
background: white;
border-radius: 50%;
display: inline-flex;
align-items: center;
justify-content: center;
margin: 0 auto 20px;
box-shadow: 0 8px 25px rgba(0,0,0,0.3);
padding: 10px;
}}
.logo img {{
width: 100px;
height: 100px;
border-radius: 50%;
object-fit: cover;
}}
.main-title {{
font-size: 28pt;
font-weight: 700;
margin: 30px 0 20px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
letter-spacing: 1px;
}}
.subtitle {{
font-size: 16pt;
font-weight: 300;
margin: 20px 0;
opacity: 0.95;
}}
.university {{
font-size: 14pt;
margin: 25px 0;
font-weight: 400;
}}
.developer-info {{
background: rgba(255,255,255,0.15);
padding: 30px;
border-radius: 12px;
margin: 40px auto;
max-width: 600px;
backdrop-filter: blur(10px);
border: 1px solid rgba(255,255,255,0.2);
}}
.developer-name {{
font-size: 24pt;
font-weight: 600;
margin: 15px 0;
text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}}
.developer-title {{
font-size: 13pt;
margin: 10px 0;
opacity: 0.9;
}}
.contact-info {{
font-size: 12pt;
margin: 15px 0;
font-weight: 400;
}}
.version-info {{
font-size: 12pt;
margin-top: 25px;
font-weight: 500;
}}
h1 {{
color: #2c3e50;
border-bottom: 3px solid #3498db;
padding-bottom: 15px;
page-break-before: always;
font-size: 20pt;
font-weight: 600;
margin: 40px 0 25px;
text-transform: uppercase;
letter-spacing: 0.5px;
}}
h1:first-of-type {{
page-break-before: auto;
}}
h2 {{
color: #34495e;
border-left: 5px solid #e74c3c;
padding-left: 20px;
font-size: 16pt;
font-weight: 600;
margin: 30px 0 20px;
background: #f8f9fa;
padding: 15px 20px;
border-radius: 0 8px 8px 0;
}}
h3 {{
color: #8e44ad;
font-size: 14pt;
font-weight: 600;
margin: 25px 0 15px;
border-bottom: 1px solid #e8e8e8;
padding-bottom: 8px;
}}
h4 {{
color: #27ae60;
font-size: 12pt;
font-weight: 600;
margin: 20px 0 10px;
}}
p {{
margin: 12px 0;
text-align: justify;
line-height: 1.8;
}}
code {{
background-color: #f1f2f6;
padding: 3px 8px;
border-radius: 4px;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 10pt;
color: #e74c3c;
border: 1px solid #ddd;
}}
pre {{
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
border: 1px solid #dee2e6;
border-radius: 8px;
padding: 20px;
font-size: 9pt;
overflow-x: auto;
margin: 20px 0;
box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}}
pre code {{
background: none;
border: none;
padding: 0;
color: #2c3e50;
}}
table {{
width: 100%;
border-collapse: collapse;
margin: 25px 0;
font-size: 10pt;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
border-radius: 8px;
overflow: hidden;
}}
th, td {{
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}}
th {{
background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
color: white;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
}}
tr:nth-child(even) {{
background-color: #f8f9fa;
}}
tr:hover {{
background-color: #e3f2fd;
}}
ul, ol {{
margin: 15px 0;
padding-left: 30px;
}}
li {{
margin: 8px 0;
line-height: 1.6;
}}
blockquote {{
border-left: 5px solid #3498db;
margin: 25px 0;
padding: 20px 25px;
background: linear-gradient(135deg, #ebf3fd 0%, #f8fbff 100%);
font-style: italic;
border-radius: 0 8px 8px 0;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}}
.highlight-box {{
background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
border: 2px solid #f39c12;
border-radius: 10px;
padding: 20px;
margin: 25px 0;
box-shadow: 0 4px 12px rgba(243,156,18,0.2);
}}
.success-box {{
background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
border: 2px solid #27ae60;
border-radius: 10px;
padding: 20px;
margin: 25px 0;
box-shadow: 0 4px 12px rgba(39,174,96,0.2);
}}
.info-box {{
background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
border: 2px solid #17a2b8;
border-radius: 10px;
padding: 20px;
margin: 25px 0;
box-shadow: 0 4px 12px rgba(23,162,184,0.2);
}}
.page-break {{
page-break-before: always;
}}
.stats-grid {{
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin: 30px 0;
}}
.stat-card {{
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 25px;
border-radius: 12px;
text-align: center;
box-shadow: 0 6px 20px rgba(102,126,234,0.3);
}}
.stat-number {{
font-size: 32pt;
font-weight: 700;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}}
.footer-section {{
background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
color: white;
padding: 40px;
border-radius: 15px;
text-align: center;
margin-top: 40px;
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}}
.toc {{
background: #f8f9fa;
border: 2px solid #e9ecef;
border-radius: 12px;
padding: 30px;
margin: 30px 0;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}}
.toc h2 {{
margin-top: 0;
color: #2c3e50;
text-align: center;
}}
@media print {{
.no-print {{
display: none;
}}
body {{
font-size: 10pt;
}}
.cover-page {{
margin-bottom: 0;
}}
}}
</style>
</head>
<body>
<div class="cover-page">
<div class="logo-container">
<div class="logo">
<img src="static/images/ulc-icam-logo.png" alt="ULC-ICAM Logo">
</div>
</div>
<h1 class="main-title">ULC-ICAM TURNIN SYSTEM</h1>
<p class="subtitle">Système de Gestion de Devoirs et Soumissions de Code</p>
<p class="university">Université Loyola du Congo - Institut Catholique d'Arts et Métiers</p>
<div class="developer-info">
<h3 style="margin-top: 0; color: white; border: none;">ULC-ICAM Turnin System</h3>
<h2 class="developer-name">Jonathan Kakesa Nayaba</h2>
<p class="developer-title">Ingénieur Logiciel & Développeur Full-Stack</p>
<p class="contact-info">📧 jkakesa9@gmail.com | 📱 +1 (438)-529-9073</p>
<p class="version-info">Décembre 2024 - Version 1.0 Production Ready</p>
</div>
</div>
{html_content}
<div class="page-break"></div>
<div class="footer-section">
<div class="logo-container">
<div class="logo">
<img src="static/images/ulc-icam-logo.png" alt="ULC-ICAM Logo">
</div>
</div>
<h2 style="color: white; border: none; margin: 20px 0;">Merci pour votre Attention</h2>
<h3 style="color: white; border: none;">Jonathan Kakesa Nayaba</h3>
<p class="developer-title">Développeur Principal</p>
<p class="contact-info">📧 jkakesa9@gmail.com | 📱 +1 (438)-529-9073</p>
<p style="margin-top: 30px; font-size: 16pt; font-weight: 600;">Questions & Démonstration Live</p>
</div>
</body>
</html>
"""
html_file = Path("ULC_ICAM_Presentation_Professional.html")
with open(html_file, 'w', encoding='utf-8') as f:
f.write(html_template)
return html_file
def convert_markdown_to_html(md_content):
"""Convertit le Markdown en HTML avec mise en forme avancée"""
import re
html = md_content
# Titres avec ancres
html = re.sub(r'^# (.*?)$', r'<h1>\1</h1>', html, flags=re.MULTILINE)
html = re.sub(r'^## (.*?)$', r'<h2>\1</h2>', html, flags=re.MULTILINE)
html = re.sub(r'^### (.*?)$', r'<h3>\1</h3>', html, flags=re.MULTILINE)
html = re.sub(r'^#### (.*?)$', r'<h4>\1</h4>', html, flags=re.MULTILINE)
# Formatage
html = re.sub(r'\*\*(.*?)\*\*', r'<strong>\1</strong>', html)
html = re.sub(r'\*(.*?)\*', r'<em>\1</em>', html)
html = re.sub(r'`(.*?)`', r'<code>\1</code>', html)
# Blocs de code avec langage
html = re.sub(r'```(\w+)?\n(.*?)```', r'<pre><code>\2</code></pre>', html, flags=re.DOTALL)
# Citations
html = re.sub(r'^> (.*?)$', r'<blockquote>\1</blockquote>', html, flags=re.MULTILINE)
# Tableaux basiques
lines = html.split('\n')
result_lines = []
in_table = False
for i, line in enumerate(lines):
if '|' in line and not in_table:
# Début de tableau
headers = [cell.strip() for cell in line.split('|')[1:-1]]
result_lines.append('<table>')
result_lines.append('<thead><tr>')
for header in headers:
result_lines.append(f'<th>{header}</th>')
result_lines.append('</tr></thead><tbody>')
in_table = True
elif '|' in line and in_table and not line.strip().startswith('|---'):
# Ligne de données
cells = [cell.strip() for cell in line.split('|')[1:-1]]
result_lines.append('<tr>')
for cell in cells:
result_lines.append(f'<td>{cell}</td>')
result_lines.append('</tr>')
elif in_table and '|' not in line:
# Fin de tableau
result_lines.append('</tbody></table>')
result_lines.append(line)
in_table = False
elif not (in_table and line.strip().startswith('|---')):
result_lines.append(line)
if in_table:
result_lines.append('</tbody></table>')
# Listes
html = '\n'.join(result_lines)
lines = html.split('\n')
result_lines = []
in_list = False
for line in lines:
if line.strip().startswith('- '):
if not in_list:
result_lines.append('<ul>')
in_list = True
result_lines.append(f'<li>{line.strip()[2:]}</li>')
elif line.strip().startswith('1. ') or re.match(r'^\d+\. ', line.strip()):
if not in_list:
result_lines.append('<ol>')
in_list = True
content = re.sub(r'^\d+\. ', '', line.strip())
result_lines.append(f'<li>{content}</li>')
else:
if in_list:
result_lines.append('</ul>' if '- ' in str(result_lines[-2:]) else '</ol>')
in_list = False
result_lines.append(line)
if in_list:
result_lines.append('</ul>')
# Paragraphes
html = '\n'.join(result_lines)
paragraphs = re.split(r'\n\s*\n', html)
html_paragraphs = []
for p in paragraphs:
p = p.strip()
if p and not re.match(r'^<[^>]+>', p):
html_paragraphs.append(f'<p>{p}</p>')
else:
html_paragraphs.append(p)
return '\n\n'.join(html_paragraphs)
def main():
print("🎓 Générateur PDF Professionnel - ULC-ICAM Turnin System")
print("=" * 60)
print("📄 Création du fichier HTML professionnel...")
html_file = create_professional_html()
if not html_file:
return False
print(f"✅ Fichier HTML créé: {html_file}")
print("\n🌐 Ouverture dans le navigateur...")
file_url = f"file:///{html_file.absolute()}"
webbrowser.open(file_url)
print("\n📋 INSTRUCTIONS POUR GÉNÉRER LE PDF:")
print("=" * 50)
print("1. ✅ Le fichier s'ouvre dans votre navigateur")
print("2. 🖨️ Appuyez sur Ctrl+P (ou Cmd+P sur Mac)")
print("3. 📄 Sélectionnez 'Enregistrer au format PDF'")
print("4. ⚙️ Configurez les options:")
print(" - Format: A4")
print(" - Marges: Normales")
print(" - Inclure les arrière-plans: OUI")
print(" - Échelle: 100%")
print("5. 💾 Enregistrez sous: 'ULC-ICAM_Turnin_System_Presentation.pdf'")
print("\n🎉 Votre présentation PDF professionnelle sera prête!")
return True
if __name__ == "__main__":
main()