1import D from"./canvas-vendor-C3fx88d4.js";import{dt as E,eo as H}from"./index-DkhxOMdR.js";import"./react-vendor-BorBU4Bs.js";import"./radix-vendor-CazrR58L.js";import"./charts-vendor-BxJanGhU.js";import"./query-vendor-dlntIC_S.js";import"./supabase-vendor-BxTHC7hl.js";import"./xlsx-vendor-DOnNs5_d.js";import"./qr-vendor-Ca1-Dxvv.js";const M={portrait:{w:595.28,h:841.89},landscape:{w:841.89,h:595.28}};function F(c){return c.replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g," ").trim()}async function A(c,w){const P=c.orientation??"portrait",e=M[P],d=Math.round(e.w/72*96),r=document.createElement("iframe");r.style.cssText=`position:fixed;left:-10000px;top:0;width:${d}px;height:600px;border:0;opacity:0;`,document.body.appendChild(r);try{const o=r.contentDocument;if(!o)throw new Error("Não foi possÃvel preparar o documento do PDF.");o.open(),o.write(E({...c,fileName:w})),o.close(),await new Promise(t=>setTimeout(t,350)),await Promise.all(Array.from(o.images).map(t=>t.complete?Promise.resolve():new Promise(n=>{t.onload=()=>n(),t.onerror=()=>n()})));const h=o.body;h.style.margin="0";const f=Math.max(h.scrollHeight,o.documentElement.scrollHeight);r.style.height=`${f}px`;const a=await D(h,{scale:2,backgroundColor:"#ffffff",windowWidth:d,width:d,height:f,useCORS:!0}),m=await H.create(),s=Math.floor(a.width*e.h/e.w),y=Math.max(1,Math.ceil(a.height/s));for(let t=0;t<y;t++){const n=Math.min(s,a.height-t*s),i=document.createElement("canvas");i.width=a.width,i.height=n;const l=i.getContext("2d");if(!l)throw new Error("Falha ao renderizar página do PDF.");l.fillStyle="#ffffff",l.fillRect(0,0,i.width,i.height),l.drawImage(a,0,-t*s);const v=await m.embedPng(i.toDataURL("image/png")),R=m.addPage([e.w,e.h]),u=n*e.w/a.width;R.drawImage(v,{x:0,y:e.h-u,width:e.w,height:u})}const x=await m.save(),b=new Blob([x],{type:"application/pdf"}),g=URL.createObjectURL(b),p=document.createElement("a");p.href=g,p.download=`${F(w)}.pdf`,p.click(),setTimeout(()=>URL.revokeObjectURL(g),2e3)}finally{r.remove()}}export{A as savePrintReportPdf};
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.