Update protectpdf.html
Browse files- protectpdf.html +23 -37
protectpdf.html
CHANGED
|
@@ -8,7 +8,8 @@
|
|
| 8 |
<meta name="description" content="Protect PDF files with password encryption and configurable permissions in your browser.">
|
| 9 |
<link rel="preconnect" href="https://cdnjs.cloudflare.com">
|
| 10 |
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
| 11 |
-
<
|
|
|
|
| 12 |
<style>
|
| 13 |
:root{--bg:#f5f7fc;--surface:#fff;--ink:#171c35;--muted:#7c849f;--line:#e6eaf3;--primary:#6558ed;--primary2:#877bff;--mint:#22b89a;--danger:#e45469;--shadow:0 18px 55px rgba(33,43,89,.08);--radius:22px}
|
| 14 |
*{box-sizing:border-box}body{margin:0;background:radial-gradient(circle at 12% 0%,#eceaff 0,transparent 30%),radial-gradient(circle at 90% 10%,#e5faf6 0,transparent 25%),var(--bg);font-family:"DM Sans",sans-serif;color:var(--ink);min-height:100vh}button,input,select{font:inherit}button{cursor:pointer}.shell{max-width:1220px;margin:auto;padding:24px 26px 60px}.topbar{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:44px}.brand{display:flex;align-items:center;gap:12px;text-decoration:none;color:inherit}.brandmark{width:44px;height:44px;border-radius:15px;background:linear-gradient(135deg,#786bff,#5145d7);display:grid;place-items:center;color:white;box-shadow:0 8px 20px #6658ed44}.brandmark svg{width:24px}.brandname{font:800 22px Manrope,sans-serif;letter-spacing:-.8px}.brandname span{color:var(--primary)}.secure-pill{display:flex;align-items:center;gap:8px;background:#fff;border:1px solid var(--line);padding:10px 14px;border-radius:99px;color:#56607b;font-size:12px;font-weight:700}.secure-pill i{width:8px;height:8px;border-radius:50%;background:var(--mint);box-shadow:0 0 0 4px #22b89a1b}.hero{text-align:center;margin:0 auto 34px;max-width:760px}.eyebrow{display:inline-flex;align-items:center;gap:8px;color:var(--primary);font-size:11px;font-weight:800;letter-spacing:1.5px;text-transform:uppercase;background:#eeecff;border:1px solid #e0dcff;border-radius:99px;padding:8px 12px}.hero h1{font:800 clamp(34px,5vw,55px)/1.08 Manrope,sans-serif;letter-spacing:-2.5px;margin:18px 0 14px}.hero h1 em{font-style:normal;background:linear-gradient(90deg,#6558ed,#a16aff);-webkit-background-clip:text;background-clip:text;color:transparent}.hero p{margin:0 auto;max-width:600px;color:var(--muted);font-size:15px;line-height:1.75}.workspace{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(320px,.85fr);gap:22px;align-items:start}.panel{background:var(--surface);border:1px solid #e8ebf4;border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}.panel-head{padding:23px 25px 18px;border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;gap:14px}.panel-title{font:800 16px Manrope,sans-serif;letter-spacing:-.3px}.panel-sub{font-size:12px;color:var(--muted);margin-top:5px}.step{font-size:11px;font-weight:800;color:var(--primary);background:#f0efff;padding:8px 11px;border-radius:10px;white-space:nowrap}.panel-body{padding:24px}.dropzone{border:1.5px dashed #c9c9ee;border-radius:18px;background:linear-gradient(135deg,#fafaff,#f5fffc);min-height:240px;display:flex;align-items:center;justify-content:center;text-align:center;padding:26px;transition:.2s}.dropzone.drag{border-color:var(--primary);background:#f0efff;transform:scale(.995)}.drop-inner{max-width:380px}.upload-icon{width:58px;height:58px;margin:0 auto 15px;display:grid;place-items:center;border-radius:18px;color:var(--primary);background:#ebe9ff}.upload-icon svg{width:28px}.dropzone h3{margin:0 0 8px;font:800 16px Manrope,sans-serif}.dropzone p{margin:0 0 17px;color:var(--muted);font-size:12px;line-height:1.65}.btn{border:0;border-radius:12px;padding:12px 17px;font-weight:800;font-size:12px;transition:transform .15s,box-shadow .15s}.btn:hover{transform:translateY(-1px)}.btn-primary{color:#fff;background:linear-gradient(135deg,#7467ff,#5749dd);box-shadow:0 9px 20px #6558ed30}.btn-light{background:#f3f4fa;color:#535c79;border:1px solid var(--line)}.file-card{display:none;align-items:center;gap:14px;padding:15px;border:1px solid var(--line);border-radius:15px;background:#fbfcff;margin-top:16px}.file-icon{width:44px;height:48px;display:grid;place-items:center;border-radius:11px;background:#fff0f1;color:#e45265;flex:none}.file-icon svg{width:22px}.file-info{min-width:0;flex:1}.file-name{font-weight:800;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.file-meta{color:var(--muted);font-size:11px;margin-top:5px}.remove-btn{border:0;background:#f5f6fb;color:#8a91a9;width:32px;height:32px;border-radius:10px;font-size:19px}.section-label{font:800 12px Manrope,sans-serif;margin:24px 0 13px;display:flex;align-items:center;justify-content:space-between;gap:12px}.section-label small{font:500 11px "DM Sans";color:var(--muted)}.field{margin-bottom:15px}.field label{display:flex;justify-content:space-between;gap:10px;font-size:12px;font-weight:700;margin-bottom:8px;color:#424a68}.field input[type=password],.field input[type=text],.field input[type=number],.field select{width:100%;padding:13px 14px;border:1px solid #e1e5f0;border-radius:11px;outline:none;color:var(--ink);background:#fff;transition:.2s}.field input:focus,.field select:focus{border-color:#8d82ff;box-shadow:0 0 0 3px #6558ed12}.input-wrap{position:relative}.input-wrap input{padding-right:48px!important}.eye{position:absolute;right:7px;top:7px;border:0;background:#f4f5fb;border-radius:8px;width:34px;height:34px;color:#69718d}.strength{display:flex;gap:5px;margin-top:9px}.strength span{height:4px;border-radius:5px;background:#e7eaf3;flex:1}.strength span.on.weak{background:#e45b6d}.strength span.on.medium{background:#efb84c}.strength span.on.strong{background:#20b99a}.strength-copy{font-size:10px;color:var(--muted);margin-top:6px}.checkline{display:flex;align-items:flex-start;gap:10px;padding:12px 13px;border:1px solid var(--line);border-radius:12px;margin:10px 0;background:#fcfcff}.checkline input{accent-color:var(--primary);margin-top:2px}.checkline strong{display:block;font-size:12px}.checkline small{display:block;color:var(--muted);font-size:11px;line-height:1.5;margin-top:4px}.permissions{display:grid;grid-template-columns:1fr 1fr;gap:10px}.permission{display:flex;align-items:flex-start;gap:9px;padding:12px;border:1px solid var(--line);border-radius:12px;background:#fff}.permission input{accent-color:var(--primary);margin-top:2px}.permission strong{font-size:11px;display:block}.permission small{display:block;font-size:10px;color:var(--muted);margin-top:4px;line-height:1.4}.info-note{font-size:11px;color:#6c7290;line-height:1.65;background:#f5f6ff;border:1px solid #e8e8ff;border-radius:12px;padding:12px 14px;margin-top:14px}.info-note b{color:#4f49b8}.side-panel .panel-body{padding:22px}.preview-card{border:1px solid var(--line);border-radius:17px;background:linear-gradient(150deg,#fbfbff,#f5f7ff);padding:22px;text-align:center}.lock-visual{width:82px;height:88px;margin:4px auto 16px;position:relative;display:grid;place-items:center}.lock-shackle{position:absolute;top:0;width:40px;height:42px;border:6px solid #786bff;border-bottom:0;border-radius:22px 22px 0 0}.lock-body{position:absolute;bottom:0;width:67px;height:52px;border-radius:14px;background:linear-gradient(135deg,#7d70ff,#5345d8);box-shadow:0 10px 18px #6558ed35;display:grid;place-items:center;color:white}.lock-body svg{width:24px}.preview-card h3{font:800 15px Manrope,sans-serif;margin:0 0 8px}.preview-card p{color:var(--muted);font-size:11px;line-height:1.65;margin:0}.summary{margin-top:17px}.summary-row{display:flex;justify-content:space-between;gap:15px;padding:12px 0;border-bottom:1px solid #edf0f6;font-size:11px}.summary-row:last-child{border-bottom:0}.summary-row span{color:var(--muted)}.summary-row strong{text-align:right;overflow-wrap:anywhere}.secure-status{display:flex;align-items:center;gap:10px;padding:12px;border-radius:12px;background:#eafaf5;color:#16896f;font-size:11px;font-weight:800;margin-top:16px}.secure-status svg{width:18px;flex:none}.actions{margin-top:19px}.actions .btn{width:100%;padding:15px}.actions .btn:disabled{opacity:.5;cursor:not-allowed;transform:none;box-shadow:none}.actions .subtext{text-align:center;color:var(--muted);font-size:10px;line-height:1.6;margin-top:10px}.progress-wrap{display:none;margin-top:16px}.progress-head{display:flex;justify-content:space-between;font-size:11px;color:#59617e;margin-bottom:8px}.progress{height:6px;background:#eceefa;border-radius:99px;overflow:hidden}.progress span{display:block;width:0;height:100%;background:linear-gradient(90deg,#6558ed,#24bea1);transition:width .2s}.result{display:none;margin-top:15px;padding:14px;border:1px solid #cdeee3;background:#f1fcf8;border-radius:13px}.result strong{font-size:12px;color:#16866e}.result p{font-size:11px;color:#5c7180;line-height:1.6;margin:6px 0 12px}.result .btn{width:100%}.trust-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-top:23px}.trust{display:flex;align-items:center;gap:12px;padding:17px;background:#ffffffad;border:1px solid #e8ebf4;border-radius:16px}.trust-icon{width:38px;height:38px;border-radius:12px;display:grid;place-items:center;background:#efedff;color:var(--primary);flex:none}.trust-icon svg{width:19px}.trust strong{display:block;font-size:11px}.trust span{display:block;font-size:10px;color:var(--muted);margin-top:4px;line-height:1.4}.footer{text-align:center;color:#9299b0;font-size:10px;margin-top:35px}.toast{position:fixed;left:50%;bottom:25px;transform:translate(-50%,20px);opacity:0;pointer-events:none;z-index:10;background:#202542;color:#fff;padding:13px 18px;border-radius:12px;box-shadow:0 15px 35px #171c3533;font-size:12px;transition:.25s;max-width:calc(100vw - 30px)}.toast.show{opacity:1;transform:translate(-50%,0)}.smallprint{font-size:10px;color:var(--muted);line-height:1.65;margin-top:10px}
|
|
@@ -114,20 +115,6 @@
|
|
| 114 |
<footer class="footer">PDFix · Practical PDF tools, designed for your workflow.</footer>
|
| 115 |
</div>
|
| 116 |
<div class="toast" id="toast" role="status" aria-live="polite"></div>
|
| 117 |
-
<script type="module">
|
| 118 |
-
import { createPdfToolkit } from "https://esm.sh/pdfstudio";
|
| 119 |
-
try {
|
| 120 |
-
window.pdfixToolkit = await createPdfToolkit({
|
| 121 |
-
wasmUrl: "https://cdn.jsdelivr.net/npm/pdfstudio/dist/qpdf.wasm"
|
| 122 |
-
});
|
| 123 |
-
window.pdfixToolkitReady = true;
|
| 124 |
-
window.dispatchEvent(new Event("pdfix-toolkit-ready"));
|
| 125 |
-
} catch (error) {
|
| 126 |
-
console.error("PDF encryption engine failed to load:", error);
|
| 127 |
-
window.pdfixToolkitReady = false;
|
| 128 |
-
window.dispatchEvent(new Event("pdfix-toolkit-failed"));
|
| 129 |
-
}
|
| 130 |
-
</script>
|
| 131 |
<script>
|
| 132 |
(() => {
|
| 133 |
const $ = id => document.getElementById(id);
|
|
@@ -172,7 +159,7 @@ try {
|
|
| 172 |
$('sumEdit').textContent=$('allowModify').checked?'Allowed':'Restricted';
|
| 173 |
$('sumAnnotate').textContent=$('allowAnnotate').checked?'Allowed':'Restricted';
|
| 174 |
$('sumOutput').textContent=safeName($('outputName').value);
|
| 175 |
-
$('protectBtn').disabled=!selectedFile;
|
| 176 |
}
|
| 177 |
$('browseBtn').addEventListener('click',()=>$('fileInput').click());
|
| 178 |
$('fileInput').addEventListener('change',e=>setFile(e.target.files[0]));
|
|
@@ -192,8 +179,9 @@ try {
|
|
| 192 |
const password=$('password').value, confirm=$('confirmPassword').value;
|
| 193 |
if(password.length<8){toast('Use a password of at least 8 characters.');$('password').focus();return;}
|
| 194 |
if(password!==confirm){toast('Passwords do not match.');$('confirmPassword').focus();return;}
|
| 195 |
-
if(!window.
|
| 196 |
-
toast('The
|
|
|
|
| 197 |
return;
|
| 198 |
}
|
| 199 |
$('protectBtn').disabled=true;$('result').style.display='none';setProgress(8,'Reading your PDF…');
|
|
@@ -204,15 +192,17 @@ try {
|
|
| 204 |
const ownerPassword = Array.from(crypto.getRandomValues(new Uint8Array(24)), b => b.toString(16).padStart(2,'0')).join('');
|
| 205 |
const print = !$('allowPrint').checked ? 'none' : ($('printQuality').value === 'low' ? 'low' : 'full');
|
| 206 |
const modify = $('allowModify').checked ? 'all' : ($('allowAnnotate').checked ? 'annotate' : 'none');
|
| 207 |
-
const encryptedBytes = await window.
|
| 208 |
-
|
| 209 |
ownerPassword,
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
|
|
|
|
|
|
| 216 |
});
|
| 217 |
setProgress(82,'Checking encrypted output…');
|
| 218 |
if(!encryptedBytes || encryptedBytes.length<10) throw new Error('The encryption engine returned an empty output file.');
|
|
@@ -234,7 +224,7 @@ try {
|
|
| 234 |
$('statusText').textContent='Could not complete protection.';
|
| 235 |
toast(err.message||'Unable to protect this PDF. Try another file.');
|
| 236 |
$('progressWrap').style.display='none';
|
| 237 |
-
}finally{$('protectBtn').disabled=!selectedFile;}
|
| 238 |
}
|
| 239 |
function download(){
|
| 240 |
if(!outputBlob){toast('Protect the PDF first.');return;}
|
|
@@ -253,16 +243,12 @@ try {
|
|
| 253 |
$('downloadBtn').addEventListener('click',download);
|
| 254 |
$('outputName').addEventListener('input',updateSummary);
|
| 255 |
updateSummary();
|
| 256 |
-
$('
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
$('protectBtn').disabled =
|
| 261 |
-
}
|
| 262 |
-
window.addEventListener('pdfix-toolkit-failed', () => {
|
| 263 |
-
$('statusText').textContent = 'Encryption engine could not load. Check your internet connection and refresh.';
|
| 264 |
-
toast('Could not load encryption engine. Check your internet connection.');
|
| 265 |
-
});
|
| 266 |
})();
|
| 267 |
</script>
|
| 268 |
</body>
|
|
|
|
| 8 |
<meta name="description" content="Protect PDF files with password encryption and configurable permissions in your browser.">
|
| 9 |
<link rel="preconnect" href="https://cdnjs.cloudflare.com">
|
| 10 |
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
| 11 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf-lib/1.17.1/pdf-lib.min.js"></script>
|
| 12 |
+
<script src="https://cdn.jsdelivr.net/npm/@pdfsmaller/pdf-encrypt@1.2.0/dist/pdf-encrypt.umd.js"></script>
|
| 13 |
<style>
|
| 14 |
:root{--bg:#f5f7fc;--surface:#fff;--ink:#171c35;--muted:#7c849f;--line:#e6eaf3;--primary:#6558ed;--primary2:#877bff;--mint:#22b89a;--danger:#e45469;--shadow:0 18px 55px rgba(33,43,89,.08);--radius:22px}
|
| 15 |
*{box-sizing:border-box}body{margin:0;background:radial-gradient(circle at 12% 0%,#eceaff 0,transparent 30%),radial-gradient(circle at 90% 10%,#e5faf6 0,transparent 25%),var(--bg);font-family:"DM Sans",sans-serif;color:var(--ink);min-height:100vh}button,input,select{font:inherit}button{cursor:pointer}.shell{max-width:1220px;margin:auto;padding:24px 26px 60px}.topbar{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:44px}.brand{display:flex;align-items:center;gap:12px;text-decoration:none;color:inherit}.brandmark{width:44px;height:44px;border-radius:15px;background:linear-gradient(135deg,#786bff,#5145d7);display:grid;place-items:center;color:white;box-shadow:0 8px 20px #6658ed44}.brandmark svg{width:24px}.brandname{font:800 22px Manrope,sans-serif;letter-spacing:-.8px}.brandname span{color:var(--primary)}.secure-pill{display:flex;align-items:center;gap:8px;background:#fff;border:1px solid var(--line);padding:10px 14px;border-radius:99px;color:#56607b;font-size:12px;font-weight:700}.secure-pill i{width:8px;height:8px;border-radius:50%;background:var(--mint);box-shadow:0 0 0 4px #22b89a1b}.hero{text-align:center;margin:0 auto 34px;max-width:760px}.eyebrow{display:inline-flex;align-items:center;gap:8px;color:var(--primary);font-size:11px;font-weight:800;letter-spacing:1.5px;text-transform:uppercase;background:#eeecff;border:1px solid #e0dcff;border-radius:99px;padding:8px 12px}.hero h1{font:800 clamp(34px,5vw,55px)/1.08 Manrope,sans-serif;letter-spacing:-2.5px;margin:18px 0 14px}.hero h1 em{font-style:normal;background:linear-gradient(90deg,#6558ed,#a16aff);-webkit-background-clip:text;background-clip:text;color:transparent}.hero p{margin:0 auto;max-width:600px;color:var(--muted);font-size:15px;line-height:1.75}.workspace{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(320px,.85fr);gap:22px;align-items:start}.panel{background:var(--surface);border:1px solid #e8ebf4;border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}.panel-head{padding:23px 25px 18px;border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;gap:14px}.panel-title{font:800 16px Manrope,sans-serif;letter-spacing:-.3px}.panel-sub{font-size:12px;color:var(--muted);margin-top:5px}.step{font-size:11px;font-weight:800;color:var(--primary);background:#f0efff;padding:8px 11px;border-radius:10px;white-space:nowrap}.panel-body{padding:24px}.dropzone{border:1.5px dashed #c9c9ee;border-radius:18px;background:linear-gradient(135deg,#fafaff,#f5fffc);min-height:240px;display:flex;align-items:center;justify-content:center;text-align:center;padding:26px;transition:.2s}.dropzone.drag{border-color:var(--primary);background:#f0efff;transform:scale(.995)}.drop-inner{max-width:380px}.upload-icon{width:58px;height:58px;margin:0 auto 15px;display:grid;place-items:center;border-radius:18px;color:var(--primary);background:#ebe9ff}.upload-icon svg{width:28px}.dropzone h3{margin:0 0 8px;font:800 16px Manrope,sans-serif}.dropzone p{margin:0 0 17px;color:var(--muted);font-size:12px;line-height:1.65}.btn{border:0;border-radius:12px;padding:12px 17px;font-weight:800;font-size:12px;transition:transform .15s,box-shadow .15s}.btn:hover{transform:translateY(-1px)}.btn-primary{color:#fff;background:linear-gradient(135deg,#7467ff,#5749dd);box-shadow:0 9px 20px #6558ed30}.btn-light{background:#f3f4fa;color:#535c79;border:1px solid var(--line)}.file-card{display:none;align-items:center;gap:14px;padding:15px;border:1px solid var(--line);border-radius:15px;background:#fbfcff;margin-top:16px}.file-icon{width:44px;height:48px;display:grid;place-items:center;border-radius:11px;background:#fff0f1;color:#e45265;flex:none}.file-icon svg{width:22px}.file-info{min-width:0;flex:1}.file-name{font-weight:800;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.file-meta{color:var(--muted);font-size:11px;margin-top:5px}.remove-btn{border:0;background:#f5f6fb;color:#8a91a9;width:32px;height:32px;border-radius:10px;font-size:19px}.section-label{font:800 12px Manrope,sans-serif;margin:24px 0 13px;display:flex;align-items:center;justify-content:space-between;gap:12px}.section-label small{font:500 11px "DM Sans";color:var(--muted)}.field{margin-bottom:15px}.field label{display:flex;justify-content:space-between;gap:10px;font-size:12px;font-weight:700;margin-bottom:8px;color:#424a68}.field input[type=password],.field input[type=text],.field input[type=number],.field select{width:100%;padding:13px 14px;border:1px solid #e1e5f0;border-radius:11px;outline:none;color:var(--ink);background:#fff;transition:.2s}.field input:focus,.field select:focus{border-color:#8d82ff;box-shadow:0 0 0 3px #6558ed12}.input-wrap{position:relative}.input-wrap input{padding-right:48px!important}.eye{position:absolute;right:7px;top:7px;border:0;background:#f4f5fb;border-radius:8px;width:34px;height:34px;color:#69718d}.strength{display:flex;gap:5px;margin-top:9px}.strength span{height:4px;border-radius:5px;background:#e7eaf3;flex:1}.strength span.on.weak{background:#e45b6d}.strength span.on.medium{background:#efb84c}.strength span.on.strong{background:#20b99a}.strength-copy{font-size:10px;color:var(--muted);margin-top:6px}.checkline{display:flex;align-items:flex-start;gap:10px;padding:12px 13px;border:1px solid var(--line);border-radius:12px;margin:10px 0;background:#fcfcff}.checkline input{accent-color:var(--primary);margin-top:2px}.checkline strong{display:block;font-size:12px}.checkline small{display:block;color:var(--muted);font-size:11px;line-height:1.5;margin-top:4px}.permissions{display:grid;grid-template-columns:1fr 1fr;gap:10px}.permission{display:flex;align-items:flex-start;gap:9px;padding:12px;border:1px solid var(--line);border-radius:12px;background:#fff}.permission input{accent-color:var(--primary);margin-top:2px}.permission strong{font-size:11px;display:block}.permission small{display:block;font-size:10px;color:var(--muted);margin-top:4px;line-height:1.4}.info-note{font-size:11px;color:#6c7290;line-height:1.65;background:#f5f6ff;border:1px solid #e8e8ff;border-radius:12px;padding:12px 14px;margin-top:14px}.info-note b{color:#4f49b8}.side-panel .panel-body{padding:22px}.preview-card{border:1px solid var(--line);border-radius:17px;background:linear-gradient(150deg,#fbfbff,#f5f7ff);padding:22px;text-align:center}.lock-visual{width:82px;height:88px;margin:4px auto 16px;position:relative;display:grid;place-items:center}.lock-shackle{position:absolute;top:0;width:40px;height:42px;border:6px solid #786bff;border-bottom:0;border-radius:22px 22px 0 0}.lock-body{position:absolute;bottom:0;width:67px;height:52px;border-radius:14px;background:linear-gradient(135deg,#7d70ff,#5345d8);box-shadow:0 10px 18px #6558ed35;display:grid;place-items:center;color:white}.lock-body svg{width:24px}.preview-card h3{font:800 15px Manrope,sans-serif;margin:0 0 8px}.preview-card p{color:var(--muted);font-size:11px;line-height:1.65;margin:0}.summary{margin-top:17px}.summary-row{display:flex;justify-content:space-between;gap:15px;padding:12px 0;border-bottom:1px solid #edf0f6;font-size:11px}.summary-row:last-child{border-bottom:0}.summary-row span{color:var(--muted)}.summary-row strong{text-align:right;overflow-wrap:anywhere}.secure-status{display:flex;align-items:center;gap:10px;padding:12px;border-radius:12px;background:#eafaf5;color:#16896f;font-size:11px;font-weight:800;margin-top:16px}.secure-status svg{width:18px;flex:none}.actions{margin-top:19px}.actions .btn{width:100%;padding:15px}.actions .btn:disabled{opacity:.5;cursor:not-allowed;transform:none;box-shadow:none}.actions .subtext{text-align:center;color:var(--muted);font-size:10px;line-height:1.6;margin-top:10px}.progress-wrap{display:none;margin-top:16px}.progress-head{display:flex;justify-content:space-between;font-size:11px;color:#59617e;margin-bottom:8px}.progress{height:6px;background:#eceefa;border-radius:99px;overflow:hidden}.progress span{display:block;width:0;height:100%;background:linear-gradient(90deg,#6558ed,#24bea1);transition:width .2s}.result{display:none;margin-top:15px;padding:14px;border:1px solid #cdeee3;background:#f1fcf8;border-radius:13px}.result strong{font-size:12px;color:#16866e}.result p{font-size:11px;color:#5c7180;line-height:1.6;margin:6px 0 12px}.result .btn{width:100%}.trust-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-top:23px}.trust{display:flex;align-items:center;gap:12px;padding:17px;background:#ffffffad;border:1px solid #e8ebf4;border-radius:16px}.trust-icon{width:38px;height:38px;border-radius:12px;display:grid;place-items:center;background:#efedff;color:var(--primary);flex:none}.trust-icon svg{width:19px}.trust strong{display:block;font-size:11px}.trust span{display:block;font-size:10px;color:var(--muted);margin-top:4px;line-height:1.4}.footer{text-align:center;color:#9299b0;font-size:10px;margin-top:35px}.toast{position:fixed;left:50%;bottom:25px;transform:translate(-50%,20px);opacity:0;pointer-events:none;z-index:10;background:#202542;color:#fff;padding:13px 18px;border-radius:12px;box-shadow:0 15px 35px #171c3533;font-size:12px;transition:.25s;max-width:calc(100vw - 30px)}.toast.show{opacity:1;transform:translate(-50%,0)}.smallprint{font-size:10px;color:var(--muted);line-height:1.65;margin-top:10px}
|
|
|
|
| 115 |
<footer class="footer">PDFix · Practical PDF tools, designed for your workflow.</footer>
|
| 116 |
</div>
|
| 117 |
<div class="toast" id="toast" role="status" aria-live="polite"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
<script>
|
| 119 |
(() => {
|
| 120 |
const $ = id => document.getElementById(id);
|
|
|
|
| 159 |
$('sumEdit').textContent=$('allowModify').checked?'Allowed':'Restricted';
|
| 160 |
$('sumAnnotate').textContent=$('allowAnnotate').checked?'Allowed':'Restricted';
|
| 161 |
$('sumOutput').textContent=safeName($('outputName').value);
|
| 162 |
+
$('protectBtn').disabled=!(selectedFile && window.PDFEncrypt && typeof window.PDFEncrypt.encryptPDF === 'function');
|
| 163 |
}
|
| 164 |
$('browseBtn').addEventListener('click',()=>$('fileInput').click());
|
| 165 |
$('fileInput').addEventListener('change',e=>setFile(e.target.files[0]));
|
|
|
|
| 179 |
const password=$('password').value, confirm=$('confirmPassword').value;
|
| 180 |
if(password.length<8){toast('Use a password of at least 8 characters.');$('password').focus();return;}
|
| 181 |
if(password!==confirm){toast('Passwords do not match.');$('confirmPassword').focus();return;}
|
| 182 |
+
if(!window.PDFEncrypt || typeof window.PDFEncrypt.encryptPDF !== 'function'){
|
| 183 |
+
toast('The encryption library did not load. Check your internet connection, then refresh this page.');
|
| 184 |
+
$('statusText').textContent='Encryption library unavailable. Check internet and refresh.';
|
| 185 |
return;
|
| 186 |
}
|
| 187 |
$('protectBtn').disabled=true;$('result').style.display='none';setProgress(8,'Reading your PDF…');
|
|
|
|
| 192 |
const ownerPassword = Array.from(crypto.getRandomValues(new Uint8Array(24)), b => b.toString(16).padStart(2,'0')).join('');
|
| 193 |
const print = !$('allowPrint').checked ? 'none' : ($('printQuality').value === 'low' ? 'low' : 'full');
|
| 194 |
const modify = $('allowModify').checked ? 'all' : ($('allowAnnotate').checked ? 'annotate' : 'none');
|
| 195 |
+
const encryptedBytes = await window.PDFEncrypt.encryptPDF(inputBytes, password, {
|
| 196 |
+
algorithm: 'AES-256',
|
| 197 |
ownerPassword,
|
| 198 |
+
allowPrinting: $('allowPrint').checked,
|
| 199 |
+
allowHighQualityPrint: $('allowPrint').checked && $('printQuality').value === 'high',
|
| 200 |
+
allowCopying: $('allowCopy').checked,
|
| 201 |
+
allowModifying: $('allowModify').checked,
|
| 202 |
+
allowAnnotating: $('allowAnnotate').checked,
|
| 203 |
+
allowFillingForms: $('allowAnnotate').checked,
|
| 204 |
+
allowExtraction: $('allowCopy').checked,
|
| 205 |
+
allowAssembly: $('allowModify').checked
|
| 206 |
});
|
| 207 |
setProgress(82,'Checking encrypted output…');
|
| 208 |
if(!encryptedBytes || encryptedBytes.length<10) throw new Error('The encryption engine returned an empty output file.');
|
|
|
|
| 224 |
$('statusText').textContent='Could not complete protection.';
|
| 225 |
toast(err.message||'Unable to protect this PDF. Try another file.');
|
| 226 |
$('progressWrap').style.display='none';
|
| 227 |
+
}finally{$('protectBtn').disabled=!(selectedFile && window.PDFEncrypt && typeof window.PDFEncrypt.encryptPDF === 'function');}
|
| 228 |
}
|
| 229 |
function download(){
|
| 230 |
if(!outputBlob){toast('Protect the PDF first.');return;}
|
|
|
|
| 243 |
$('downloadBtn').addEventListener('click',download);
|
| 244 |
$('outputName').addEventListener('input',updateSummary);
|
| 245 |
updateSummary();
|
| 246 |
+
$('statusText').textContent = (window.PDFEncrypt && typeof window.PDFEncrypt.encryptPDF === 'function')
|
| 247 |
+
? 'AES-256 encryption engine ready. Your PDF stays on this device.'
|
| 248 |
+
: 'Encryption library unavailable. Check internet and refresh.';
|
| 249 |
+
if (!(window.PDFEncrypt && typeof window.PDFEncrypt.encryptPDF === 'function')) {
|
| 250 |
+
$('protectBtn').disabled = true;
|
| 251 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
})();
|
| 253 |
</script>
|
| 254 |
</body>
|