<!DOCTYPE html>
<html>
<head>
<title>PDF結合アプリ</title>
<style>
body {
margin: 40px;
text-align: center;
}
h1 {
color: #333333;
}
label {
margin-top: 20px;
}
input[type="file"] {
display: none;
}
.btn {
background-color: #4CAF50;
border: none;
color: white;
padding: 10px 24px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 20px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>PDF結合アプリ</h1>
<label for="files">PDFファイルを選択してください(最大5つ):</label>
<input type="file" id="files" multiple accept=".pdf">
<br>
<button class="btn" onclick="mergePDF()">PDF結合</button>
<script>
function mergePDF() {
const fileInput = document.getElementById("files");
const fileCount = fileInput.files.length;
if (fileCount === 0) {
alert("少なくとも1つのPDFファイルを選択してください。");
return;
}
if (fileCount > 5) {
alert("最大5つまでのPDFファイルを選択してください。");
return;
}
const fileArray = Array.from(fileInput.files);
const mergedBlob = new Blob(fileArray, { type: "application/pdf" });
const mergedURL = URL.createObjectURL(mergedBlob);
const downloadLink = document.createElement("a");
downloadLink.href = mergedURL;
downloadLink.download = "merged.pdf";
downloadLink.click();
}
</script>
</body>
</html>
ジョーク:
プログラマの顔の片方だけに筋肉があるのはなぜでしょう?
答え: コーディングのためにマウスを持ち上げるから!