Spaces:
Sleeping
Sleeping
Update templates/philosophie.html
Browse files- templates/philosophie.html +264 -76
templates/philosophie.html
CHANGED
@@ -27,103 +27,254 @@
|
|
27 |
border-radius: 8px;
|
28 |
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
|
29 |
}
|
30 |
-
h1 {
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
button:hover { background-color: #3498db; }
|
34 |
button:disabled { background-color: #95a5a6; cursor: not-allowed; }
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
37 |
.error { color: #c0392b; text-align: center; margin-top: 20px; }
|
38 |
|
39 |
-
/* ---
|
40 |
.dissertation-paper {
|
41 |
font-family: 'Kalam', cursive;
|
42 |
-
font-size:
|
43 |
color: #1a2a4c;
|
44 |
background-color: #fdfaf4;
|
45 |
-
line-height: 1.
|
46 |
-
background-image: linear-gradient(transparent
|
47 |
-
background-size: 100%
|
48 |
-
border-left:
|
49 |
-
padding
|
50 |
-
margin: 40px
|
51 |
-
|
52 |
-
|
53 |
-
padding-right: 30px;
|
54 |
-
box-shadow: 5px 5px 15px rgba(0,0,0,0.2);
|
55 |
}
|
56 |
|
57 |
-
/*
|
58 |
-
.dissertation-paper
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
border
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
.dissertation-paper .
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
</style>
|
87 |
</head>
|
88 |
<body>
|
|
|
89 |
<div class="container">
|
90 |
<h1>Assistant de Dissertation Philosophique</h1>
|
91 |
<form id="philo-form">
|
92 |
-
<textarea id="question" name="question" placeholder="Entrez votre sujet de dissertation ici..."></textarea>
|
93 |
<button type="submit" id="submit-btn">Générer la dissertation</button>
|
94 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
<div id="loader" class="loader"></div>
|
96 |
<div id="result-container"></div>
|
97 |
</div>
|
98 |
|
99 |
<script>
|
100 |
-
// Le code de la logique de formulaire reste identique...
|
101 |
document.addEventListener('DOMContentLoaded', () => {
|
102 |
const form = document.getElementById('philo-form');
|
103 |
const submitBtn = document.getElementById('submit-btn');
|
|
|
104 |
const loader = document.getElementById('loader');
|
105 |
const resultContainer = document.getElementById('result-container');
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
form.addEventListener('submit', async (event) => {
|
108 |
event.preventDefault();
|
109 |
const question = document.getElementById('question').value.trim();
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
submitBtn.disabled = true;
|
112 |
submitBtn.textContent = 'Génération en cours...';
|
113 |
loader.style.display = 'block';
|
114 |
resultContainer.innerHTML = '';
|
|
|
115 |
try {
|
116 |
const response = await fetch('/api/generate_dissertation', {
|
117 |
method: 'POST',
|
118 |
headers: { 'Content-Type': 'application/json' },
|
119 |
body: JSON.stringify({ question: question })
|
120 |
});
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
122 |
const data = await response.json();
|
123 |
renderDissertation(data);
|
|
|
124 |
} catch (error) {
|
125 |
showError(error.message);
|
126 |
} finally {
|
|
|
127 |
submitBtn.disabled = false;
|
128 |
submitBtn.textContent = 'Générer la dissertation';
|
129 |
loader.style.display = 'none';
|
@@ -131,65 +282,102 @@
|
|
131 |
});
|
132 |
|
133 |
function renderDissertation(data) {
|
134 |
-
// Le code de rendu HTML reste identique
|
135 |
let html = `
|
136 |
<div id="dissertation-content" class="dissertation-paper">
|
137 |
<h2>Sujet : ${data.sujet}</h2>
|
138 |
<p class="prof">Prof : ${data.prof}</p>
|
139 |
<h3>Introduction</h3>
|
140 |
-
<p class="indented">${data.introduction.replace(/\n/g, '
|
141 |
`;
|
|
|
142 |
data.parties.forEach((partie, index) => {
|
143 |
html += `<div class="development-block">`;
|
144 |
-
html += `<
|
145 |
partie.arguments.forEach(arg => {
|
146 |
-
html += `<p class="indented">${arg.paragraphe_argumentatif.replace(/\n/g, '
|
147 |
});
|
148 |
html += `</div>`;
|
149 |
-
|
|
|
|
|
|
|
150 |
});
|
|
|
151 |
html += `
|
152 |
<h3>Conclusion</h3>
|
153 |
-
<p class="indented">${data.conclusion.replace(/\n/g, '
|
154 |
<div class="pdf-button-container">
|
155 |
<button class="pdf-button" id="download-pdf">Télécharger en PDF</button>
|
156 |
</div>
|
157 |
</div>
|
158 |
`;
|
|
|
159 |
resultContainer.innerHTML = html;
|
|
|
|
|
160 |
document.getElementById('download-pdf').addEventListener('click', generatePDF);
|
161 |
}
|
162 |
|
163 |
-
// --- FONCTION generatePDF() CORRIGÉE ---
|
164 |
function generatePDF() {
|
165 |
const element = document.getElementById('dissertation-content');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
-
//
|
168 |
-
const
|
169 |
-
|
170 |
-
|
|
|
171 |
|
172 |
-
//
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
const options = {
|
177 |
-
margin: [
|
178 |
-
|
179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
};
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
}
|
194 |
|
195 |
function showError(message) {
|
|
|
27 |
border-radius: 8px;
|
28 |
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
|
29 |
}
|
30 |
+
h1 {
|
31 |
+
text-align: center;
|
32 |
+
color: #2c3e50;
|
33 |
+
}
|
34 |
+
textarea {
|
35 |
+
width: 100%;
|
36 |
+
padding: 10px;
|
37 |
+
border-radius: 4px;
|
38 |
+
border: 1px solid #ddd;
|
39 |
+
min-height: 80px;
|
40 |
+
margin-bottom: 10px;
|
41 |
+
font-size: 16px;
|
42 |
+
box-sizing: border-box;
|
43 |
+
}
|
44 |
+
button {
|
45 |
+
display: block;
|
46 |
+
width: 100%;
|
47 |
+
padding: 15px;
|
48 |
+
background-color: #2980b9;
|
49 |
+
color: white;
|
50 |
+
border: none;
|
51 |
+
border-radius: 5px;
|
52 |
+
font-size: 18px;
|
53 |
+
cursor: pointer;
|
54 |
+
transition: background-color 0.3s;
|
55 |
+
}
|
56 |
button:hover { background-color: #3498db; }
|
57 |
button:disabled { background-color: #95a5a6; cursor: not-allowed; }
|
58 |
+
|
59 |
+
.loader {
|
60 |
+
display: none;
|
61 |
+
border: 8px solid #f3f3f3;
|
62 |
+
border-top: 8px solid #3498db;
|
63 |
+
border-radius: 50%;
|
64 |
+
width: 50px;
|
65 |
+
height: 50px;
|
66 |
+
animation: spin 1s linear infinite;
|
67 |
+
margin: 20px auto;
|
68 |
+
}
|
69 |
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
70 |
.error { color: #c0392b; text-align: center; margin-top: 20px; }
|
71 |
|
72 |
+
/* --- Styles du Rendu "Cahier" --- */
|
73 |
.dissertation-paper {
|
74 |
font-family: 'Kalam', cursive;
|
75 |
+
font-size: 18px;
|
76 |
color: #1a2a4c;
|
77 |
background-color: #fdfaf4;
|
78 |
+
line-height: 1.6;
|
79 |
+
background-image: linear-gradient(transparent 94%, #d8e2ee 95%, transparent 96%);
|
80 |
+
background-size: 100% 25px;
|
81 |
+
border-left: 3px solid #ffaaab;
|
82 |
+
padding: 30px 30px 30px 60px;
|
83 |
+
margin: 40px 0;
|
84 |
+
min-height: 500px;
|
85 |
+
position: relative;
|
|
|
|
|
86 |
}
|
87 |
|
88 |
+
/* Marges pour les trous de classeur */
|
89 |
+
.dissertation-paper::before {
|
90 |
+
content: '';
|
91 |
+
position: absolute;
|
92 |
+
left: 20px;
|
93 |
+
top: 50px;
|
94 |
+
width: 15px;
|
95 |
+
height: 15px;
|
96 |
+
border-radius: 50%;
|
97 |
+
background-color: #f4f4f9;
|
98 |
+
border: 2px solid #ddd;
|
99 |
+
box-shadow: 0 100px 0 #f4f4f9, 0 100px 0 2px #ddd, 0 200px 0 #f4f4f9, 0 200px 0 2px #ddd;
|
100 |
+
}
|
101 |
+
|
102 |
+
.dissertation-paper h2 {
|
103 |
+
font-size: 1.4em;
|
104 |
+
text-align: center;
|
105 |
+
margin-bottom: 30px;
|
106 |
+
color: #1a2a4c;
|
107 |
+
text-decoration: underline;
|
108 |
+
}
|
109 |
+
|
110 |
+
.dissertation-paper h3 {
|
111 |
+
font-size: 1.1em;
|
112 |
+
margin: 40px 0 20px 0;
|
113 |
+
text-transform: uppercase;
|
114 |
+
text-decoration: underline;
|
115 |
+
color: #1a2a4c;
|
116 |
+
}
|
117 |
+
|
118 |
+
.dissertation-paper .development-block {
|
119 |
+
margin: 30px 0;
|
120 |
+
}
|
121 |
+
|
122 |
+
.dissertation-paper p {
|
123 |
+
text-align: justify;
|
124 |
+
margin: 15px 0;
|
125 |
+
color: #1a2a4c;
|
126 |
+
}
|
127 |
+
|
128 |
+
.dissertation-paper .prof {
|
129 |
+
text-align: center;
|
130 |
+
font-style: italic;
|
131 |
+
margin-bottom: 30px;
|
132 |
+
}
|
133 |
+
|
134 |
+
.dissertation-paper .indented {
|
135 |
+
text-indent: 2em;
|
136 |
+
}
|
137 |
+
|
138 |
+
.dissertation-paper .transition {
|
139 |
+
margin: 25px 0;
|
140 |
+
font-style: italic;
|
141 |
+
color: #4a6a9c;
|
142 |
}
|
143 |
|
144 |
+
.dissertation-paper .pdf-button-container {
|
145 |
+
text-align: center;
|
146 |
+
margin-top: 40px;
|
147 |
+
}
|
148 |
+
|
149 |
+
.dissertation-paper .pdf-button {
|
150 |
+
font-family: 'Lato', sans-serif;
|
151 |
+
font-size: 16px;
|
152 |
+
padding: 10px 20px;
|
153 |
+
width: auto;
|
154 |
+
display: inline-block;
|
155 |
+
}
|
156 |
+
|
157 |
+
/* Styles pour une meilleure compatibilité PDF */
|
158 |
+
@media print {
|
159 |
+
.dissertation-paper {
|
160 |
+
margin: 0;
|
161 |
+
box-shadow: none;
|
162 |
+
border: none;
|
163 |
+
}
|
164 |
+
}
|
165 |
</style>
|
166 |
</head>
|
167 |
<body>
|
168 |
+
|
169 |
<div class="container">
|
170 |
<h1>Assistant de Dissertation Philosophique</h1>
|
171 |
<form id="philo-form">
|
172 |
+
<textarea id="question" name="question" placeholder="Entrez votre sujet de dissertation ici... Par exemple : 'Sommes-nous toujours conscients ?'"></textarea>
|
173 |
<button type="submit" id="submit-btn">Générer la dissertation</button>
|
174 |
</form>
|
175 |
+
|
176 |
+
<!-- Section de test pour démonstration -->
|
177 |
+
<div style="margin-top: 30px; padding: 20px; background-color: #e8f4f8; border-radius: 5px;">
|
178 |
+
<h3>Test de génération PDF</h3>
|
179 |
+
<p>Cliquez sur le bouton ci-dessous pour tester la génération PDF avec un contenu d'exemple :</p>
|
180 |
+
<button id="test-demo" style="background-color: #27ae60; margin-top: 10px;">Générer exemple de dissertation</button>
|
181 |
+
</div>
|
182 |
+
|
183 |
<div id="loader" class="loader"></div>
|
184 |
<div id="result-container"></div>
|
185 |
</div>
|
186 |
|
187 |
<script>
|
|
|
188 |
document.addEventListener('DOMContentLoaded', () => {
|
189 |
const form = document.getElementById('philo-form');
|
190 |
const submitBtn = document.getElementById('submit-btn');
|
191 |
+
const testDemoBtn = document.getElementById('test-demo');
|
192 |
const loader = document.getElementById('loader');
|
193 |
const resultContainer = document.getElementById('result-container');
|
194 |
|
195 |
+
// Gestionnaire pour le bouton de test
|
196 |
+
testDemoBtn.addEventListener('click', () => {
|
197 |
+
const sampleData = {
|
198 |
+
sujet: "Sommes-nous toujours conscients ?",
|
199 |
+
prof: "M. Rousseau",
|
200 |
+
introduction: "La conscience semble être ce qui nous définit en tant qu'êtres humains. Pourtant, nous passons une grande partie de notre existence dans des états où notre conscience paraît altérée ou diminuée : le sommeil, la distraction, l'automatisme. Cette question nous amène à interroger la nature même de la conscience et ses limites.\n\nLa problématique qui se pose est la suivante : la conscience est-elle un état permanent de l'esprit humain, ou connaît-elle des interruptions et des variations ? Nous examinerons d'abord les arguments qui plaident pour une conscience permanente, puis nous analyserons les phénomènes qui semblent la remettre en question, avant de proposer une conception nuancée de la conscience.",
|
201 |
+
parties: [
|
202 |
+
{
|
203 |
+
chapeau: "I. La thèse de la conscience permanente",
|
204 |
+
arguments: [
|
205 |
+
{
|
206 |
+
paragraphe_argumentatif: "Descartes, dans ses Méditations métaphysiques, établit que la pensée est l'essence même de l'âme. « Je pense, donc je suis » implique une conscience constante de soi. Selon cette perspective, même dans le sommeil ou la distraction, une forme de conscience subsiste toujours, car penser c'est être conscient."
|
207 |
+
},
|
208 |
+
{
|
209 |
+
paragraphe_argumentatif: "Cette permanence de la conscience peut également être comprise comme une continuité de l'identité personnelle. John Locke montre que c'est la conscience de nos expériences passées qui assure notre identité à travers le temps. Sans cette continuité, nous ne serions plus la même personne."
|
210 |
+
}
|
211 |
+
],
|
212 |
+
transition: "Cependant, cette vision de la conscience permanente se heurte à des objections importantes issues de l'observation de nos états mentaux quotidiens."
|
213 |
+
},
|
214 |
+
{
|
215 |
+
chapeau: "II. Les limites et interruptions de la conscience",
|
216 |
+
arguments: [
|
217 |
+
{
|
218 |
+
paragraphe_argumentatif: "Le sommeil profond constitue un défi majeur pour la thèse de la conscience permanente. Pendant certaines phases du sommeil, nous n'avons aucune expérience consciente, aucun souvenir. Comment alors maintenir que nous sommes toujours conscients ?"
|
219 |
+
},
|
220 |
+
{
|
221 |
+
paragraphe_argumentatif: "Henri Bergson met en évidence les phénomènes d'automatisme dans la vie quotidienne. Nous accomplissons de nombreuses actions sans y prêter attention consciente : marcher, conduire sur un trajet familier, ou répéter des gestes habituels. Ces comportements révèlent des zones d'inconscience dans notre existence éveillée."
|
222 |
+
}
|
223 |
+
],
|
224 |
+
transition: "Ces observations nous invitent à repenser la nature même de la conscience et à adopter une approche plus nuancée."
|
225 |
+
},
|
226 |
+
{
|
227 |
+
chapeau: "III. Pour une conception graduée de la conscience",
|
228 |
+
arguments: [
|
229 |
+
{
|
230 |
+
paragraphe_argumentatif: "Plutôt que de concevoir la conscience comme un état binaire (présent ou absent), il convient de la comprendre comme un phénomène à degrés. William James propose l'idée d'un « courant de conscience » qui varie en intensité et en clarté selon les moments et les situations."
|
231 |
+
},
|
232 |
+
{
|
233 |
+
paragraphe_argumentatif: "Cette conception permet de réconcilier les observations contradictoires : nous sommes toujours conscients dans le sens où il y a toujours une forme de présence à soi ou au monde, mais cette conscience varie en intensité, en clarté et en contenu. Même dans le sommeil, une conscience minimale subsiste qui nous permet de nous réveiller."
|
234 |
+
}
|
235 |
+
]
|
236 |
+
}
|
237 |
+
],
|
238 |
+
conclusion: "La question de la permanence de la conscience ne peut recevoir de réponse tranchée. Si nous ne sommes pas toujours pleinement conscients au sens d'une vigilance maximale et d'une réflexivité complète, il semble néanmoins qu'une forme de conscience, même minimale, nous accompagne en permanence.\n\nCette réflexion nous enseigne que la conscience humaine est plus complexe et plus nuancée qu'il n'y paraît. Elle nous invite à être attentifs aux différents degrés de notre présence au monde et à nous-mêmes, et à cultiver une conscience plus éveillée de notre propre conscience."
|
239 |
+
};
|
240 |
+
|
241 |
+
renderDissertation(sampleData);
|
242 |
+
});
|
243 |
+
|
244 |
form.addEventListener('submit', async (event) => {
|
245 |
event.preventDefault();
|
246 |
const question = document.getElementById('question').value.trim();
|
247 |
+
|
248 |
+
if (!question) {
|
249 |
+
showError("Veuillez entrer un sujet de dissertation.");
|
250 |
+
return;
|
251 |
+
}
|
252 |
+
|
253 |
+
// UI management
|
254 |
submitBtn.disabled = true;
|
255 |
submitBtn.textContent = 'Génération en cours...';
|
256 |
loader.style.display = 'block';
|
257 |
resultContainer.innerHTML = '';
|
258 |
+
|
259 |
try {
|
260 |
const response = await fetch('/api/generate_dissertation', {
|
261 |
method: 'POST',
|
262 |
headers: { 'Content-Type': 'application/json' },
|
263 |
body: JSON.stringify({ question: question })
|
264 |
});
|
265 |
+
|
266 |
+
if (!response.ok) {
|
267 |
+
const errorData = await response.json();
|
268 |
+
throw new Error(errorData.error || "Une erreur inconnue est survenue.");
|
269 |
+
}
|
270 |
+
|
271 |
const data = await response.json();
|
272 |
renderDissertation(data);
|
273 |
+
|
274 |
} catch (error) {
|
275 |
showError(error.message);
|
276 |
} finally {
|
277 |
+
// Reset UI
|
278 |
submitBtn.disabled = false;
|
279 |
submitBtn.textContent = 'Générer la dissertation';
|
280 |
loader.style.display = 'none';
|
|
|
282 |
});
|
283 |
|
284 |
function renderDissertation(data) {
|
|
|
285 |
let html = `
|
286 |
<div id="dissertation-content" class="dissertation-paper">
|
287 |
<h2>Sujet : ${data.sujet}</h2>
|
288 |
<p class="prof">Prof : ${data.prof}</p>
|
289 |
<h3>Introduction</h3>
|
290 |
+
<p class="indented">${data.introduction.replace(/\n/g, '</p><p class="indented">')}</p>
|
291 |
`;
|
292 |
+
|
293 |
data.parties.forEach((partie, index) => {
|
294 |
html += `<div class="development-block">`;
|
295 |
+
html += `<h3>${partie.chapeau}</h3>`;
|
296 |
partie.arguments.forEach(arg => {
|
297 |
+
html += `<p class="indented">${arg.paragraphe_argumentatif.replace(/\n/g, '</p><p class="indented">')}</p>`;
|
298 |
});
|
299 |
html += `</div>`;
|
300 |
+
|
301 |
+
if (partie.transition) {
|
302 |
+
html += `<p class="indented transition">${partie.transition.replace(/\n/g, '</p><p class="indented transition">')}</p>`;
|
303 |
+
}
|
304 |
});
|
305 |
+
|
306 |
html += `
|
307 |
<h3>Conclusion</h3>
|
308 |
+
<p class="indented">${data.conclusion.replace(/\n/g, '</p><p class="indented">')}</p>
|
309 |
<div class="pdf-button-container">
|
310 |
<button class="pdf-button" id="download-pdf">Télécharger en PDF</button>
|
311 |
</div>
|
312 |
</div>
|
313 |
`;
|
314 |
+
|
315 |
resultContainer.innerHTML = html;
|
316 |
+
|
317 |
+
// Attach event listener to the newly created button
|
318 |
document.getElementById('download-pdf').addEventListener('click', generatePDF);
|
319 |
}
|
320 |
|
|
|
321 |
function generatePDF() {
|
322 |
const element = document.getElementById('dissertation-content');
|
323 |
+
if (!element) {
|
324 |
+
showError("Erreur : contenu de la dissertation non trouvé.");
|
325 |
+
return;
|
326 |
+
}
|
327 |
+
|
328 |
+
// Clone l'élément pour éviter de modifier l'original
|
329 |
+
const clone = element.cloneNode(true);
|
330 |
|
331 |
+
// Supprimer le bouton du clone
|
332 |
+
const pdfButton = clone.querySelector('.pdf-button-container');
|
333 |
+
if (pdfButton) {
|
334 |
+
pdfButton.remove();
|
335 |
+
}
|
336 |
|
337 |
+
// Créer un conteneur temporaire
|
338 |
+
const tempContainer = document.createElement('div');
|
339 |
+
tempContainer.style.position = 'absolute';
|
340 |
+
tempContainer.style.left = '-9999px';
|
341 |
+
tempContainer.style.top = '0';
|
342 |
+
tempContainer.style.width = '210mm'; // Largeur A4
|
343 |
+
tempContainer.appendChild(clone);
|
344 |
+
document.body.appendChild(tempContainer);
|
345 |
|
346 |
const options = {
|
347 |
+
margin: [10, 10, 10, 10],
|
348 |
+
filename: 'dissertation-philosophie.pdf',
|
349 |
+
image: { type: 'jpeg', quality: 0.98 },
|
350 |
+
html2canvas: {
|
351 |
+
scale: 2,
|
352 |
+
useCORS: true,
|
353 |
+
allowTaint: true,
|
354 |
+
backgroundColor: '#fdfaf4'
|
355 |
+
},
|
356 |
+
jsPDF: {
|
357 |
+
unit: 'mm',
|
358 |
+
format: 'a4',
|
359 |
+
orientation: 'portrait',
|
360 |
+
compressPDF: true
|
361 |
+
}
|
362 |
};
|
363 |
+
|
364 |
+
html2pdf()
|
365 |
+
.set(options)
|
366 |
+
.from(tempContainer)
|
367 |
+
.save()
|
368 |
+
.then(() => {
|
369 |
+
// Nettoyer le conteneur temporaire
|
370 |
+
document.body.removeChild(tempContainer);
|
371 |
+
console.log('PDF généré avec succès');
|
372 |
+
})
|
373 |
+
.catch((error) => {
|
374 |
+
console.error('Erreur lors de la génération du PDF:', error);
|
375 |
+
showError('Erreur lors de la génération du PDF. Veuillez réessayer.');
|
376 |
+
// Nettoyer le conteneur temporaire même en cas d'erreur
|
377 |
+
if (document.body.contains(tempContainer)) {
|
378 |
+
document.body.removeChild(tempContainer);
|
379 |
+
}
|
380 |
+
});
|
381 |
}
|
382 |
|
383 |
function showError(message) {
|