-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
86 lines (75 loc) · 1.94 KB
/
index.html
File metadata and controls
86 lines (75 loc) · 1.94 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
<!DOCTYPE html>
<html>
<head>
<title>MCQ PDF Generator</title>
<style>
body {
font-family: sans-serif;
padding: 30px;
max-width: 800px;
margin: auto;
}
textarea {
width: 100%;
height: 300px;
font-family: monospace;
font-size: 14px;
margin-bottom: 20px;
}
button {
padding: 10px 20px;
font-size: 16px;
}
</style>
</head>
<body>
<h1>MCQ PDF Generator (Send HTML)</h1>
<textarea id="htmlContent">
<h1>Sample MCQ Test</h1>
<div>
<p><strong>1. What is the capital of France?</strong></p>
<ul>
<li>A) Berlin</li>
<li>B) Madrid</li>
<li>C) Paris</li>
<li>D) Rome</li>
</ul>
</div>
<div>
<p><strong>2. What is 5 x 5?</strong></p>
<ul>
<li>A) 10</li>
<li>B) 20</li>
<li>C) 25</li>
<li>D) 30</li>
</ul>
</div>
</textarea>
<button onclick="sendHTML()">Generate PDF</button>
<script>
async function sendHTML() {
const content = document.getElementById("htmlContent").value;
const response = await fetch('https://html-to-pdf-converter-8gx1.onrender.com/api/v1/pdf/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ content })
});
if (!response.ok) {
console.log("Error:", await response.json());
alert("Error generating PDF");
return;
}
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'mcq.pdf';
document.body.appendChild(a);
a.click();
a.remove();
}
</script>
</body>
</html>