PageSourceSearch

https://okrapdf.com/assets/chunk-qiRdZVpA.js

js okrapdf.com collected 2026-10-04 18:44:23 UTC 5,897 bytes, 2 lines download raw bytes

1import{ap as L,bh as P,bi as w,br as R,r as n,j as e,aC as U,bs as G,cm as X}from"./app-RspSqd3x.js";import{u as H}from"./chunk-DrZhLOss.js";import{PDFDocument as J,StandardFonts as K,rgb as Q}from"./chunk-Cq3dQO8u.js";import{d as V,c as W}from"./chunk-B7JTdlXm.js";import{c as Y}from"./chunk-LiKUHNLZ.js";import{P as C,T as k,S as I,E as Z,a as ee,c as te,b as se}from"./chunk-D9ZsrbJn.js";import{D as ae}from"./chunk-iNVkXVTp.js";import"./chunk-0DKwTJ9B.js";import"./chunk-DctFPoo1.js";import"./chunk-DKtbx33k.js";const oe=L("studio.bates.stamp")(function*(s,B,b){const{position:g,fontSize:i,margin:a}=b,p=yield*P("pdf","bates-load",()=>J.load(s)),d=yield*P("pdf","bates-font",()=>p.embedFont(K.Courier)),f=yield*w("pdf","bates-pages",()=>p.getPages());yield*w("pdf","bates-validate-sequence",()=>V(b.startNumber??1,f.length));for(const[h,v]of f.entries()){const j=yield*Y;yield*w("pdf","bates-page",()=>{const{width:u,height:m}=v.getSize(),S=B(h,new Date(j)),c=d.widthOfTextAtSize(S,i);let r=0,o=0;switch(g){case"bottom-left":r=a,o=a;break;case"bottom-center":r=(u-c)/2,o=a;break;case"bottom-right":r=u-c-a,o=a;break;case"top-left":r=a,o=m-a-i;break;case"top-center":r=(u-c)/2,o=m-a-i;break;case"top-right":r=u-c-a,o=m-a-i;break}v.drawText(S,{x:r,y:o,size:i,font:d,color:Q(0,0,0)})})}return yield*P("pdf","bates-save",()=>p.save())}),ne=[{v:"top-left",label:"Top left"},{v:"top-center",label:"Top center"},{v:"top-right",label:"Top right"},{v:"bottom-left",label:"Bottom left"},{v:"bottom-center",label:"Bottom center"},{v:"bottom-right",label:"Bottom right"}];function ge(){const{doc:s,openBytes:B,notify:b}=R(),[g,i]=n.useState("DOC-"),[a,p]=n.useState(""),[d,f]=n.useState(1),[h,v]=n.useState(6),[j,u]=n.useState("bottom-right"),[m,S]=n.useState(10),[c,r]=n.useState(30),[o,M]=n.useState(!1),[O,T]=n.useState(null),[E,D]=n.useState(null),{busy:$,run:z}=H(s,B,()=>{T(null),D(null)});if(!s)return null;const A=(t,l=new Date)=>{const N=d+t,y=String(N).padStart(h,"0"),_=o?` ${l.toLocaleDateString("en-US")}`:"";return`${g}${y}${a}${_}`},F=t=>{z(({openOutput:l,commit:N})=>U(function*(){yield*N(()=>{T(null),D(null)});const y=yield*oe(s.bytes,A,{position:j,fontSize:m,margin:c,startNumber:d});t&&(yield*w("download","edit-download",()=>G(y,X(s.name,"-bates")))),yield*l(y,s.name,!t),yield*N(()=>{D(t?"Bates numbers added — download started.":"Bates numbers added in place. Use Download in the top bar to save."),b(`Stamped ${s.pageCount} page${s.pageCount===1?"":"s"}`)})}),l=>T(`Bates numbering failed: ${l instanceof Error?l.message:"unexpected error"}`))},q=Math.min(3,s.pageCount),x=W(d,s.pageCount);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(C,{label:"Number format",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-xs text-muted-foreground",children:"Prefix"}),e.jsx(k,{value:g,onChange:t=>i(t.currentTarget.value),placeholder:"DOC-",className:"font-mono"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-xs text-muted-foreground",children:"Suffix (optional)"}),e.jsx(k,{value:a,onChange:t=>p(t.currentTarget.value),placeholder:"-CONF",className:"font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"studio-bates-start",className:"mb-1 block text-xs text-muted-foreground",children:"Starting number"}),e.jsx(k,{id:"studio-bates-start",type:"number",min:1,max:Number.MAX_SAFE_INTEGER-(s.pageCount-1),step:1,"aria-invalid":!!x,value:d,onChange:t=>f(Math.max(1,Number(t.currentTarget.value)))})]}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-xs text-muted-foreground",children:"Number of digits"}),e.jsx(I,{value:h,onChange:t=>v(Number(t.currentTarget.value)),children:[4,5,6,7,8].map(t=>e.jsxs("option",{value:t,children:[t," digits (","0".repeat(t-1),"1)"]},t))})]})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 pt-1",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:t=>M(t.currentTarget.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e.jsx("span",{className:"text-sm text-foreground",children:"Include date stamp"})]})]}),e.jsx(C,{label:"Position",children:e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:ne.map(t=>e.jsx("button",{type:"button",onClick:()=>u(t.v),className:`rounded-md border px-1.5 py-2 text-xs font-medium transition-colors ${j===t.v?"border-selected-line bg-selected text-selected-foreground":"border-border bg-secondary text-muted-foreground hover:bg-accent hover:text-foreground"}`,children:t.label},t.v))})}),e.jsx(C,{label:"Layout",children:e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-xs text-muted-foreground",children:"Font size"}),e.jsx(I,{value:m,onChange:t=>S(Number(t.currentTarget.value)),children:[8,9,10,11,12].map(t=>e.jsxs("option",{value:t,children:[t,"pt"]},t))})]}),e.jsxs("div",{children:[e.jsx("span",{className:"mb-1 block text-xs text-muted-foreground",children:"Margin (pt)"}),e.jsx(k,{type:"number",min:10,max:100,value:c,onChange:t=>r(Number(t.currentTarget.value))})]})]})}),e.jsx(C,{label:"Preview",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Array.from({length:q},(t,l)=>e.jsx("span",{className:"inline-block rounded-md bg-muted px-3 py-1.5 font-mono text-sm text-foreground",children:x?"—":A(l)},l)),s.pageCount>3?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["… +",s.pageCount-3," more"]}):null]})}),e.jsx(Z,{message:x??O}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ee,{busy:$,disabled:!!x,onClick:()=>void F(!1),children:"Apply to open document"}),e.jsxs(te,{disabled:$||!!x,onClick:()=>void F(!0),children:[e.jsx(ae,{className:"h-4 w-4"}),"Apply & download"]})]}),E?e.jsx(se,{children:E}):null]})}export{ge as default};
2//# sourceMappingURL=chunk-qiRdZVpA.js.map

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.