1import{r as t,u as g,j as e,L as D}from"./index-j7I9Tmll.js";import{P as S}from"./PdfPagePreview-or-1mmoF.js";import{P as L,S as F,r as T}from"./PDFButton-D40prZLX.js";import{f as M}from"./pdfEditor-C_FHqbws.js";import"./pdf.worker.min-DT7iqwIP.js";import"./browser-cLhBeQPl.js";function k(){const[p,x]=t.useState(`<h1>My document</h1> 2<p>Start writing HTML here.</p>`),[o,u]=t.useState(!1),[b,i]=t.useState("Enter HTML to create a PDF."),[f,c]=t.useState(""),[r,d]=t.useState(null),s=t.useRef(null);g({title:"HTML to PDF Converter Online Free | Kernel Tools",description:"Convert HTML text to PDF in your browser. No uploads required.",keywords:["html to pdf","convert html to pdf","web page to pdf","html pdf converter"],structuredData:{"@context":"https://schema.org","@type":"SoftwareApplication",name:"HTML to PDF",applicationCategory:"UtilitiesApplication",operatingSystem:"Web",url:"https://kerneltools.dev/html-to-pdf",offers:{"@type":"Offer",price:"0",priceCurrency:"USD"}}}),t.useEffect(()=>()=>{s.current&&URL.revokeObjectURL(s.current)},[]);async function P(){if(!o)try{u(!0),d(null),c(""),c(""),i("Creating PDFâ¦");const a=new DOMParser().parseFromString(p,"text/html").body.innerText.trim();if(!a)throw new Error("Enter some HTML content first.");const n=await L.create({updateMetadata:!1}),j=await n.embedFont(F.Helvetica),y=a.split(/\r?\n/);let m=n.addPage([595,842]),l=794;for(const w of y)l<40&&(m=n.addPage([595,842]),l=794),m.drawText(w.slice(0,110),{x:40,y:l,size:11,font:j,color:T(.1,.1,.1)}),l-=16;const v=await n.save({updateMetadata:!1}),h=new Blob([v],{type:"application/pdf"});s.current&&URL.revokeObjectURL(s.current),s.current=URL.createObjectURL(h),d({url:s.current,size:h.size}),i("Your PDF is ready.")}catch(a){c(a.message||"Could not create the PDF.")}finally{u(!1)}}return e.jsxs("div",{className:"pdf-tools-page",children:[e.jsx(D,{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:"HTML to PDF"}),e.jsx("p",{children:"Turn HTML content into a PDF in your browser."})]}),e.jsxs("section",{className:"pdf-tool-workspace pdf-conversion-desk pdf-conversion-source",children:[e.jsxs("fieldset",{className:"pdf-desk-controls",disabled:o,children:[e.jsx("legend",{children:"HTML source editor"}),e.jsx("label",{htmlFor:"html-source",children:e.jsx("strong",{children:"HTML source"})}),e.jsx("textarea",{id:"html-source",className:"pdf-ocr-result",value:p,onChange:a=>{x(a.target.value),d(null),i("Source changed. Create a new PDF.")},"aria-label":"HTML source"}),e.jsx("p",{className:"pdf-tool-warning",children:"Basic conversion preserves readable HTML text. External assets, JavaScript, advanced CSS, web fonts, and exact visual layout are not reproduced."}),e.jsxs("div",{className:"pdf-tool-actions",children:[e.jsx("button",{className:"btn btn-primary",disabled:o,onClick:P,children:o?"Creatingâ¦":"Create PDF"}),r&&e.jsxs("a",{className:"btn btn-primary",href:r.url,download:"html.pdf",children:["Download PDF (",M(r.size),")"]})]}),e.jsx("p",{role:"status","aria-live":"polite",children:b}),f&&e.jsx("p",{className:"pdf-tool-error",role:"alert",children:f})]}),e.jsx(S,{url:r==null?void 0:r.url,disabled:o,title:"Generated PDF preview"})]})]})}export{k 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.