PageSourceSearch

https://kerneltools.dev/assets/CompressPdf-sX75s51k.js

js kerneltools.dev collected 2026-10-02 01:52:51 UTC 5,834 bytes, 1 lines download raw bytes

1import{r as t,u as k,j as e,L as z}from"./index-j7I9Tmll.js";import{f as h,i as N,M as w,p as R}from"./pdfEditor-C_FHqbws.js";function O(){const[r,b]=t.useState(null),[p,C]=t.useState("balanced"),[n,u]=t.useState(!1),[P,a]=t.useState("Choose a PDF to compress."),[x,c]=t.useState(""),[o,m]=t.useState(null),y=t.useRef(null),f=t.useRef(null),l=t.useRef(null);k({title:"Compress PDF Online Free — Reduce PDF Size | Kernel Tools",description:"Compress a PDF in your browser. Choose a quality level and download a smaller flattened PDF with no upload.",keywords:["compress pdf","reduce pdf size","shrink pdf file","pdf compressor"],structuredData:{"@context":"https://schema.org","@type":"SoftwareApplication",name:"Compress PDF",applicationCategory:"UtilitiesApplication",operatingSystem:"Web",url:"https://kerneltools.dev/compress-pdf",offers:{"@type":"Offer",price:"0",priceCurrency:"USD"}}}),t.useEffect(()=>()=>{var s;(s=f.current)==null||s.terminate(),l.current&&URL.revokeObjectURL(l.current)},[]);function g(){l.current&&URL.revokeObjectURL(l.current),l.current=null,m(null)}function j(s){C(s),g(),a("Quality changed. Compress again to create a new result.")}function F(s){var d;const i=s==null?void 0:s[0];if(!i||!N(i))return c("Choose one PDF file.");if(i.size>w)return c("Choose a PDF up to 100 MB.");R(i.size)==="confirm"&&!window.confirm("This PDF is over 25 MB and compression may use significant memory. Continue?")||((d=f.current)==null||d.terminate(),l.current&&URL.revokeObjectURL(l.current),l.current=null,m(null),c(""),b(i),a("Ready to compress."))}function D(){if(!r||n)return;g(),u(!0),c(""),a("Rendering and compressing pages…");const s=new Worker(new URL("/assets/compress.worker-kSLj5yZf.js",import.meta.url),{type:"module"});f.current=s,s.onmessage=({data:i})=>{if(i.type==="progress"&&a(`Compressing pages… ${Math.round(i.value*100)}%`),i.type==="result"){const d=new Blob([i.bytes],{type:"application/pdf"});l.current=URL.createObjectURL(d),m({url:l.current,size:d.size}),u(!1),a("Your compressed PDF is ready.")}i.type==="error"&&(c(i.message),u(!1))},r.arrayBuffer().then(i=>s.postMessage({type:"compress",bytes:new Uint8Array(i),profile:p},[i]))}return e.jsxs("div",{className:"pdf-tools-page",children:[e.jsx(z,{className:"pdf-tools-back",to:"/pdf-tools",children:"← All PDF tools"}),e.jsxs("header",{className:"pdf-tools-heading",children:[e.jsx("span",{className:"pdf-tools-eyebrow",children:"PROCESSED IN YOUR BROWSER · NO UPLOADS"}),e.jsx("h1",{children:"Compress PDF"}),e.jsxs("p",{children:["Make a smaller PDF by recompressing its pages.",e.jsx("br",{}),"Choose the quality that fits your document."]})]}),e.jsxs("section",{className:"pdf-tool-workspace","aria-label":"Compression workspace",children:[e.jsxs("div",{className:"pdf-compression-layout",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"pdf-tool-drop",children:[e.jsx("span",{className:"pdf-tool-symbol",children:"↓"}),e.jsx("h2",{children:"Choose a PDF"}),e.jsx("p",{children:"Your file stays in this browser."}),e.jsx("input",{ref:y,hidden:!0,type:"file",accept:"application/pdf,.pdf",onChange:s=>{F(s.target.files),s.target.value=""}}),e.jsx("button",{className:"btn btn-primary",disabled:n,onClick:()=>y.current.click(),children:"Choose PDF"}),e.jsx("small",{children:"One PDF · up to 100 MB · 250 pages"})]}),r&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pdf-tool-list-heading",children:[e.jsx("h2",{children:r.name}),e.jsx("span",{children:h(r.size)})]}),e.jsxs("fieldset",{className:"pdf-compress-options",disabled:n,children:[e.jsx("legend",{children:"Compression level"}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:"profile",checked:p==="low",onChange:()=>j("low")})," Smallest file"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:"profile",checked:p==="balanced",onChange:()=>j("balanced")})," Balanced quality"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:"profile",checked:p==="high",onChange:()=>j("high")})," Higher quality"]})]})]})]}),e.jsxs("aside",{className:"pdf-size-comparison","aria-label":"File size comparison",children:[e.jsx("span",{className:"explorer-kicker",children:"Measured result"}),e.jsx("h2",{children:"Before & after"}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Original PDF"}),e.jsx("dd",{children:r?h(r.size):"Choose a file"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Output PDF"}),e.jsx("dd",{children:o?h(o.size):n?"Processing…":"Not created yet"})]})]}),o&&r&&e.jsx("p",{className:"pdf-size-difference",children:o.size<r.size?`${Math.round((1-o.size/r.size)*100)}% smaller`:o.size>r.size?`${Math.round((o.size/r.size-1)*100)}% larger`:"Same file size"}),e.jsx("p",{children:o&&r&&o.size>=r.size?"This output is not smaller. Keep your original if size is y
1our priority.":"Savings depend on the source document. Size is measured only after processing."})]})]}),e.jsx("p",{className:"pdf-tool-warning",children:"This method flattens pages into images. The output does not retain selectable text, forms, links, annotations, or accessibility tags."}),e.jsxs("div",{className:"pdf-tool-actions",children:[r&&e.jsx("button",{className:"btn btn-primary",disabled:n,onClick:D,children:n?"Compressing…":"Compress PDF"}),n&&e.jsx("button",{className:"btn btn-ghost",onClick:()=>{var s;(s=f.current)==null||s.terminate(),u(!1),a("Compression cancelled.")},children:"Cancel"}),o&&e.jsxs("a",{className:"btn btn-primary",href:o.url,download:"compressed.pdf",children:["Download compressed PDF (",h(o.size),")"]})]}),e.jsx("p",{role:"status","aria-live":"polite",children:P}),x&&e.jsx("p",{className:"pdf-tool-error",role:"alert",children:x}),e.jsx("p",{className:"pdf-tool-privacy",children:"Your PDF is processed only on this device and is never uploaded."})]})]})}export{O as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.