-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdf.html
More file actions
56 lines (49 loc) · 1.39 KB
/
Copy pathpdf.html
File metadata and controls
56 lines (49 loc) · 1.39 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
#pdf-container {
display: flex;
flex-wrap: wrap;
}
.filePlacer {
position: relative;
width: 100%;
/* Set the width to 100% */
height: 800px
}
</style>
</head>
<body>
<input type="file" accept=".pdf" multiple id="pdf-selector">
<div id="pdf-container"></div>
<script>
const pdfData = document.getElementById("pdf-selector");
const pdfContainer = document.getElementById("pdf-container");
pdfData.addEventListener("change", function () {
const pdfFiles = pdfData.files;
for (let i = 0; i < pdfFiles.length; i++) {
const pdfFile = pdfFiles[i];
if (pdfFile) {
const reader = new FileReader();
reader.onload = function (event) {
const newElement = document.createElement("div");
newElement.classList.add("filePlacer");
const file = event.target.result;
newElement.innerHTML = `<embed src="${file}" type="application/pdf">`;
pdfContainer.appendChild(newElement);
}
reader.readAsDataURL(pdfFile);
}
}
})
</script>
</body>
</html>