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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
|
| 7 |
+
<title>PDFKing - PDF Document Analyzer</title>
|
| 8 |
+
|
| 9 |
+
<meta
|
| 10 |
+
name="description"
|
| 11 |
+
content="PDFKing browser-based PDF document analyzer. Inspect PDF files locally and view basic document information."
|
| 12 |
+
>
|
| 13 |
+
|
| 14 |
+
<style>
|
| 15 |
+
* {
|
| 16 |
+
box-sizing: border-box;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
body {
|
| 20 |
+
margin: 0;
|
| 21 |
+
min-height: 100vh;
|
| 22 |
+
font-family:
|
| 23 |
+
Inter,
|
| 24 |
+
-apple-system,
|
| 25 |
+
BlinkMacSystemFont,
|
| 26 |
+
"Segoe UI",
|
| 27 |
+
Arial,
|
| 28 |
+
sans-serif;
|
| 29 |
+
background:
|
| 30 |
+
radial-gradient(
|
| 31 |
+
circle at top right,
|
| 32 |
+
rgba(37, 99, 235, 0.10),
|
| 33 |
+
transparent 35%
|
| 34 |
+
),
|
| 35 |
+
#f6f8fc;
|
| 36 |
+
color: #172033;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.page {
|
| 40 |
+
width: min(1000px, calc(100% - 32px));
|
| 41 |
+
margin: 0 auto;
|
| 42 |
+
padding: 50px 0 60px;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
.header {
|
| 46 |
+
text-align: center;
|
| 47 |
+
margin-bottom: 34px;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.logo {
|
| 51 |
+
width: 64px;
|
| 52 |
+
height: 64px;
|
| 53 |
+
margin: 0 auto 18px;
|
| 54 |
+
display: grid;
|
| 55 |
+
place-items: center;
|
| 56 |
+
border-radius: 18px;
|
| 57 |
+
background: linear-gradient(135deg, #2563eb, #4f46e5);
|
| 58 |
+
color: white;
|
| 59 |
+
font-weight: 800;
|
| 60 |
+
font-size: 15px;
|
| 61 |
+
box-shadow: 0 12px 30px rgba(37, 99, 235, 0.25);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
.header h1 {
|
| 65 |
+
margin: 0;
|
| 66 |
+
font-size: clamp(30px, 5vw, 46px);
|
| 67 |
+
letter-spacing: -1.5px;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.header p {
|
| 71 |
+
max-width: 650px;
|
| 72 |
+
margin: 12px auto 0;
|
| 73 |
+
color: #697386;
|
| 74 |
+
font-size: 17px;
|
| 75 |
+
line-height: 1.6;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.card {
|
| 79 |
+
background: white;
|
| 80 |
+
border: 1px solid #e5e9f2;
|
| 81 |
+
border-radius: 24px;
|
| 82 |
+
padding: 28px;
|
| 83 |
+
box-shadow: 0 18px 50px rgba(20, 30, 50, 0.08);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
.drop-zone {
|
| 87 |
+
border: 2px dashed #cbd5e1;
|
| 88 |
+
border-radius: 20px;
|
| 89 |
+
padding: 60px 25px;
|
| 90 |
+
text-align: center;
|
| 91 |
+
background: #fbfcff;
|
| 92 |
+
transition: 0.2s ease;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.drop-zone.dragover {
|
| 96 |
+
border-color: #2563eb;
|
| 97 |
+
background: #eff6ff;
|
| 98 |
+
transform: translateY(-2px);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
.upload-icon {
|
| 102 |
+
width: 64px;
|
| 103 |
+
height: 64px;
|
| 104 |
+
margin: 0 auto 18px;
|
| 105 |
+
border-radius: 50%;
|
| 106 |
+
display: grid;
|
| 107 |
+
place-items: center;
|
| 108 |
+
background: #eff6ff;
|
| 109 |
+
color: #2563eb;
|
| 110 |
+
font-size: 28px;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.drop-zone h2 {
|
| 114 |
+
margin: 0;
|
| 115 |
+
font-size: 24px;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
.drop-zone p {
|
| 119 |
+
margin: 10px 0 22px;
|
| 120 |
+
color: #707b8d;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
.button {
|
| 124 |
+
display: inline-flex;
|
| 125 |
+
align-items: center;
|
| 126 |
+
justify-content: center;
|
| 127 |
+
padding: 13px 22px;
|
| 128 |
+
border-radius: 11px;
|
| 129 |
+
background: #2563eb;
|
| 130 |
+
color: white;
|
| 131 |
+
font-weight: 700;
|
| 132 |
+
cursor: pointer;
|
| 133 |
+
border: 0;
|
| 134 |
+
transition: 0.2s ease;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
.button:hover {
|
| 138 |
+
background: #1d4ed8;
|
| 139 |
+
transform: translateY(-1px);
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.hint {
|
| 143 |
+
display: block;
|
| 144 |
+
margin-top: 14px;
|
| 145 |
+
color: #8a94a6;
|
| 146 |
+
font-size: 13px;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.result {
|
| 150 |
+
display: none;
|
| 151 |
+
margin-top: 24px;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
.result.show {
|
| 155 |
+
display: block;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
.result-header {
|
| 159 |
+
display: flex;
|
| 160 |
+
justify-content: space-between;
|
| 161 |
+
align-items: center;
|
| 162 |
+
gap: 15px;
|
| 163 |
+
margin-bottom: 14px;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.result-header h3 {
|
| 167 |
+
margin: 0;
|
| 168 |
+
font-size: 19px;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
.status {
|
| 172 |
+
padding: 7px 11px;
|
| 173 |
+
border-radius: 999px;
|
| 174 |
+
background: #dcfce7;
|
| 175 |
+
color: #15803d;
|
| 176 |
+
font-size: 13px;
|
| 177 |
+
font-weight: 700;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
.info-grid {
|
| 181 |
+
display: grid;
|
| 182 |
+
grid-template-columns: repeat(2, 1fr);
|
| 183 |
+
gap: 12px;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
.info {
|
| 187 |
+
padding: 17px;
|
| 188 |
+
border-radius: 14px;
|
| 189 |
+
background: #f8fafc;
|
| 190 |
+
border: 1px solid #edf0f5;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
.info span {
|
| 194 |
+
display: block;
|
| 195 |
+
color: #7b8494;
|
| 196 |
+
font-size: 12px;
|
| 197 |
+
margin-bottom: 6px;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
.info strong {
|
| 201 |
+
font-size: 15px;
|
| 202 |
+
word-break: break-word;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
.footer {
|
| 206 |
+
text-align: center;
|
| 207 |
+
margin-top: 28px;
|
| 208 |
+
color: #7b8494;
|
| 209 |
+
font-size: 14px;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
.footer a {
|
| 213 |
+
color: #2563eb;
|
| 214 |
+
text-decoration: none;
|
| 215 |
+
font-weight: 700;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
@media (max-width: 650px) {
|
| 219 |
+
.page {
|
| 220 |
+
padding-top: 30px;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
.card {
|
| 224 |
+
padding: 16px;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
.drop-zone {
|
| 228 |
+
padding: 45px 18px;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
.info-grid {
|
| 232 |
+
grid-template-columns: 1fr;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
.result-header {
|
| 236 |
+
align-items: flex-start;
|
| 237 |
+
flex-direction: column;
|
| 238 |
+
}
|
| 239 |
+
}
|
| 240 |
+
</style>
|
| 241 |
+
</head>
|
| 242 |
+
|
| 243 |
+
<body>
|
| 244 |
+
|
| 245 |
+
<main class="page">
|
| 246 |
+
|
| 247 |
+
<header class="header">
|
| 248 |
+
|
| 249 |
+
<div class="logo">PDF</div>
|
| 250 |
+
|
| 251 |
+
<h1>PDF Document Analyzer</h1>
|
| 252 |
+
|
| 253 |
+
<p>
|
| 254 |
+
Inspect a PDF file directly in your browser and view
|
| 255 |
+
basic document information without uploading it to a server.
|
| 256 |
+
</p>
|
| 257 |
+
|
| 258 |
+
</header>
|
| 259 |
+
|
| 260 |
+
<section class="card">
|
| 261 |
+
|
| 262 |
+
<div class="drop-zone" id="dropZone">
|
| 263 |
+
|
| 264 |
+
<div class="upload-icon">↑</div>
|
| 265 |
+
|
| 266 |
+
<h2>Drop your PDF here</h2>
|
| 267 |
+
|
| 268 |
+
<p>
|
| 269 |
+
or choose a PDF file from your device
|
| 270 |
+
</p>
|
| 271 |
+
|
| 272 |
+
<label class="button">
|
| 273 |
+
|
| 274 |
+
Choose PDF
|
| 275 |
+
|
| 276 |
+
<input
|
| 277 |
+
id="fileInput"
|
| 278 |
+
type="file"
|
| 279 |
+
accept=".pdf,application/pdf"
|
| 280 |
+
hidden
|
| 281 |
+
>
|
| 282 |
+
|
| 283 |
+
</label>
|
| 284 |
+
|
| 285 |
+
<small class="hint">
|
| 286 |
+
Your file is inspected locally in this demo.
|
| 287 |
+
</small>
|
| 288 |
+
|
| 289 |
+
</div>
|
| 290 |
+
|
| 291 |
+
<div class="result" id="result">
|
| 292 |
+
|
| 293 |
+
<div class="result-header">
|
| 294 |
+
|
| 295 |
+
<h3>Document Information</h3>
|
| 296 |
+
|
| 297 |
+
<span class="status">
|
| 298 |
+
PDF detected
|
| 299 |
+
</span>
|
| 300 |
+
|
| 301 |
+
</div>
|
| 302 |
+
|
| 303 |
+
<div class="info-grid">
|
| 304 |
+
|
| 305 |
+
<div class="info">
|
| 306 |
+
<span>File name</span>
|
| 307 |
+
<strong id="fileName">—</strong>
|
| 308 |
+
</div>
|
| 309 |
+
|
| 310 |
+
<div class="info">
|
| 311 |
+
<span>File size</span>
|
| 312 |
+
<strong id="fileSize">—</strong>
|
| 313 |
+
</div>
|
| 314 |
+
|
| 315 |
+
<div class="info">
|
| 316 |
+
<span>File type</span>
|
| 317 |
+
<strong id="fileType">—</strong>
|
| 318 |
+
</div>
|
| 319 |
+
|
| 320 |
+
<div class="info">
|
| 321 |
+
<span>PDF signature</span>
|
| 322 |
+
<strong id="fileSignature">—</strong>
|
| 323 |
+
</div>
|
| 324 |
+
|
| 325 |
+
</div>
|
| 326 |
+
|
| 327 |
+
</div>
|
| 328 |
+
|
| 329 |
+
</section>
|
| 330 |
+
|
| 331 |
+
<footer class="footer">
|
| 332 |
+
|
| 333 |
+
PDFKing — Free PDF tools for everyday document workflows.
|
| 334 |
+
|
| 335 |
+
<br>
|
| 336 |
+
|
| 337 |
+
<a
|
| 338 |
+
href="https://pdfking.app/"
|
| 339 |
+
target="_blank"
|
| 340 |
+
rel="noopener noreferrer"
|
| 341 |
+
>
|
| 342 |
+
Visit PDFKing
|
| 343 |
+
</a>
|
| 344 |
+
|
| 345 |
+
</footer>
|
| 346 |
+
|
| 347 |
+
</main>
|
| 348 |
+
|
| 349 |
+
<script>
|
| 350 |
+
|
| 351 |
+
const fileInput =
|
| 352 |
+
document.getElementById("fileInput");
|
| 353 |
+
|
| 354 |
+
const dropZone =
|
| 355 |
+
document.getElementById("dropZone");
|
| 356 |
+
|
| 357 |
+
const result =
|
| 358 |
+
document.getElementById("result");
|
| 359 |
+
|
| 360 |
+
const fileName =
|
| 361 |
+
document.getElementById("fileName");
|
| 362 |
+
|
| 363 |
+
const fileSize =
|
| 364 |
+
document.getElementById("fileSize");
|
| 365 |
+
|
| 366 |
+
const fileType =
|
| 367 |
+
document.getElementById("fileType");
|
| 368 |
+
|
| 369 |
+
const fileSignature =
|
| 370 |
+
document.getElementById("fileSignature");
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
fileInput.addEventListener(
|
| 374 |
+
"change",
|
| 375 |
+
() => {
|
| 376 |
+
|
| 377 |
+
if (fileInput.files.length) {
|
| 378 |
+
analyzePDF(fileInput.files[0]);
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
}
|
| 382 |
+
);
|
| 383 |
+
|
| 384 |
+
|
| 385 |
+
["dragenter", "dragover"].forEach(
|
| 386 |
+
eventName => {
|
| 387 |
+
|
| 388 |
+
dropZone.addEventListener(
|
| 389 |
+
eventName,
|
| 390 |
+
event => {
|
| 391 |
+
|
| 392 |
+
event.preventDefault();
|
| 393 |
+
|
| 394 |
+
dropZone.classList.add("dragover");
|
| 395 |
+
|
| 396 |
+
}
|
| 397 |
+
);
|
| 398 |
+
|
| 399 |
+
}
|
| 400 |
+
);
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
["dragleave", "drop"].forEach(
|
| 404 |
+
eventName => {
|
| 405 |
+
|
| 406 |
+
dropZone.addEventListener(
|
| 407 |
+
eventName,
|
| 408 |
+
event => {
|
| 409 |
+
|
| 410 |
+
event.preventDefault();
|
| 411 |
+
|
| 412 |
+
dropZone.classList.remove("dragover");
|
| 413 |
+
|
| 414 |
+
}
|
| 415 |
+
);
|
| 416 |
+
|
| 417 |
+
}
|
| 418 |
+
);
|
| 419 |
+
|
| 420 |
+
|
| 421 |
+
dropZone.addEventListener(
|
| 422 |
+
"drop",
|
| 423 |
+
event => {
|
| 424 |
+
|
| 425 |
+
const file =
|
| 426 |
+
event.dataTransfer.files[0];
|
| 427 |
+
|
| 428 |
+
if (file) {
|
| 429 |
+
analyzePDF(file);
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
}
|
| 433 |
+
);
|
| 434 |
+
|
| 435 |
+
|
| 436 |
+
async function analyzePDF(file) {
|
| 437 |
+
|
| 438 |
+
const header =
|
| 439 |
+
await readHeader(file);
|
| 440 |
+
|
| 441 |
+
const isPDF =
|
| 442 |
+
header.startsWith("%PDF-");
|
| 443 |
+
|
| 444 |
+
if (!isPDF) {
|
| 445 |
+
|
| 446 |
+
alert(
|
| 447 |
+
"The selected file does not appear to be a valid PDF."
|
| 448 |
+
);
|
| 449 |
+
|
| 450 |
+
return;
|
| 451 |
+
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
fileName.textContent =
|
| 456 |
+
file.name;
|
| 457 |
+
|
| 458 |
+
fileSize.textContent =
|
| 459 |
+
formatBytes(file.size);
|
| 460 |
+
|
| 461 |
+
fileType.textContent =
|
| 462 |
+
file.type || "application/pdf";
|
| 463 |
+
|
| 464 |
+
fileSignature.textContent =
|
| 465 |
+
header;
|
| 466 |
+
|
| 467 |
+
|
| 468 |
+
result.classList.add("show");
|
| 469 |
+
|
| 470 |
+
}
|
| 471 |
+
|
| 472 |
+
|
| 473 |
+
function readHeader(file) {
|
| 474 |
+
|
| 475 |
+
return new Promise(resolve => {
|
| 476 |
+
|
| 477 |
+
const reader =
|
| 478 |
+
new FileReader();
|
| 479 |
+
|
| 480 |
+
reader.onload =
|
| 481 |
+
() => {
|
| 482 |
+
|
| 483 |
+
const bytes =
|
| 484 |
+
new Uint8Array(
|
| 485 |
+
reader.result
|
| 486 |
+
);
|
| 487 |
+
|
| 488 |
+
const header =
|
| 489 |
+
new TextDecoder().decode(bytes);
|
| 490 |
+
|
| 491 |
+
resolve(header);
|
| 492 |
+
|
| 493 |
+
};
|
| 494 |
+
|
| 495 |
+
reader.readAsArrayBuffer(
|
| 496 |
+
file.slice(0, 8)
|
| 497 |
+
);
|
| 498 |
+
|
| 499 |
+
});
|
| 500 |
+
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
function formatBytes(bytes) {
|
| 505 |
+
|
| 506 |
+
if (bytes === 0) {
|
| 507 |
+
return "0 Bytes";
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
const units =
|
| 511 |
+
[
|
| 512 |
+
"Bytes",
|
| 513 |
+
"KB",
|
| 514 |
+
"MB",
|
| 515 |
+
"GB"
|
| 516 |
+
];
|
| 517 |
+
|
| 518 |
+
const index =
|
| 519 |
+
Math.floor(
|
| 520 |
+
Math.log(bytes) /
|
| 521 |
+
Math.log(1024)
|
| 522 |
+
);
|
| 523 |
+
|
| 524 |
+
return (
|
| 525 |
+
(bytes /
|
| 526 |
+
Math.pow(1024, index)
|
| 527 |
+
).toFixed(2)
|
| 528 |
+
+ " "
|
| 529 |
+
+ units[index]
|
| 530 |
+
);
|
| 531 |
+
|
| 532 |
+
}
|
| 533 |
+
|
| 534 |
+
</script>
|
| 535 |
+
|
| 536 |
+
</body>
|
| 537 |
+
</html>
|