feat: the print file is a 300 DPI PNG, in parts of up to 15 m (item 13)
All checks were successful
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Integration suite on a real stack (push) Successful in 4m55s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m27s

FlexiPRINT's Spot OK 1 makes the white from transparency and reads it
reliably only from a PNG (Dropstar's third round, item 13): each order item
is now DTF-N-item-I.png, 300 DPI, RGBA on a transparent background, with its
footer; a film over 15 m leaves as DTF-N-item-I-pK.png parts, each with
"Parte K/N" in its footer, cut between pieces of loose art when it can be.

app/printpng.py never holds a whole sheet: the film is composed and written
in bands. Pillow encodes each band (it picks the PNG filters) and one zlib
stream takes them; a long PNG sheet is read band by band by wrapping its
compressed rows as small PNGs; a PDF page is drawn band by band at 300 DPI by
PDFium (pypdfium2, a self-contained wheel); loose art is turned and scaled
once. A 57 x 220 cm sheet peaks at 191 MB, a 15 m film at 279 MB.

The parts of an item are dtf_local.print_parts (print_files.upload_id stays
the first); the board, the final approval, the folders and the cleanup see
every part, and the Kanban approves and downloads them all. A large PNG or
PDF is now generated like any other; only other large formats go to hand
preparation, and the original no longer stands in as the print file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-03 16:53:35 -03:00
parent bd1e1772a7
commit 353935bed3
12 changed files with 810 additions and 141 deletions

View File

@@ -1428,7 +1428,8 @@ function contractionList(order){
function approveParts(order,main=true){
const ready=readyFinals(order), all=ready.every(Boolean), many=ready.length>1;
const files=node('div',undefined,'files');
if(all)ready.forEach((r,i)=>files.append(fileRow(r.name,(many?'Item '+(i+1)+', ':'')+FINAL_TITLE[r.source],downloadFile(r.upload_id))));
if(all)ready.forEach((r,i)=>r.files.forEach((f,k)=>files.append(fileRow(f.name,(many?'Item '+(i+1)+', ':'')+FINAL_TITLE[r.source]+
(r.files.length>1?', parte '+(k+1)+' de '+r.files.length:''),downloadFile(f.upload_id)))));
const text=all?'Baixe e confira. É este arquivo que vai para a impressão.':ready.some(Boolean)
?'Alguns itens já têm arquivo pronto; envie o arquivo preparado dos outros.'
:'Nenhum arquivo pronto para aprovar como está: envie o arquivo preparado para a impressão.';
@@ -1593,20 +1594,25 @@ function pickupDialog(order){
const isPickup=order=>order.snapshot.freight?.service==='pickup';
// ---- Final files: the file each item is printed from, approved by an operator.
const finalDone=order=>order.snapshot.items.every((_,index)=>(order.final_items||[]).includes(index));
const FINAL_SOURCE={correction:'correção do cliente',generated:'PDF gerado',original:'original'};
const FINAL_TITLE={correction:'Correção do cliente',generated:'PDF gerado pelo sistema',original:'Original do cliente'};
// Per item, a file that can be approved as it is, or null: the customer's
// correction, or else the generated PDF (or the original that already is one).
// After a correction, a generated file reproduces artwork nobody wants printed.
const FINAL_SOURCE={correction:'correção do cliente',generated:'arquivo gerado',original:'original'};
const FINAL_TITLE={correction:'Correção do cliente',generated:'Gerado pelo sistema',original:'Original do cliente'};
// What the system generated for an item: one PNG, or the parts of a film
// over 15 m (item 13). An item generated before parts has just its file.
const generatedFiles=row=>row.parts?.length?row.parts:[{upload_id:row.upload_id,name:row.name}];
// Per item, the files that can be approved as they are, or null: the
// customer's correction, or else what the system generated (or the original
// that already was one). After a correction, a generated file reproduces
// artwork nobody wants printed.
function readyFinals(order){
const fixes=order.corrections||[];
return order.snapshot.items.map((item,index)=>{
const fix=fixes.find(f=>f.item_index===index);
if(fix)return fix.expired?null:{upload_id:fix.upload_id,name:fix.name,source:'correction',label:'Correção do cliente ('+fix.name+')'};
if(fix)return fix.expired?null:{files:[{upload_id:fix.upload_id,name:fix.name}],name:fix.name,source:'correction',label:'Correção do cliente ('+fix.name+')'};
const made=fixes.length?null:(order.print_files||[]).find(r=>r.item_index===index&&r.status==='ready');
if(!made)return null;
const original=made.detail?.source==='original';
return {upload_id:made.upload_id,name:made.name,source:original?'original':'generated',label:(original?'O original (':'PDF gerado (')+made.name+')'};
const original=made.detail?.source==='original', files=generatedFiles(made);
const names=files.length>1?files.length+' partes, '+files[0].name+' a '+files[files.length-1].name:files[0].name;
return {files,name:files[0].name,source:original?'original':'generated',label:(original?'O original (':'Gerado pelo sistema (')+names+')'};
});
}
async function approveReady(order,ready){
@@ -1614,7 +1620,8 @@ async function approveReady(order,ready){
if(!await ask('Aprovar o arquivo final?','Conferiu? É este arquivo que vai para a impressão: '+
ready.map((r,i)=>(many?'item '+(i+1)+', ':'')+r.label).join('; ')+'.','Aprovar arquivo final',{host:$('drawer')}))return;
const note='Aprovado como está: '+[...new Set(ready.map(r=>FINAL_SOURCE[r.source]))].join(', ');
await api('/orders/'+order.id+'/final-files',{version:order.version,files:ready.map((r,i)=>({item_index:i,upload_id:r.upload_id})),note});
await api('/orders/'+order.id+'/final-files',{version:order.version,
files:ready.flatMap((r,i)=>r.files.map(f=>({item_index:i,upload_id:f.upload_id}))),note});
await load();say(mayMove(order.state,'tra')?'Arquivo final aprovado. Agora é só mover para Arte conferida.':'Arquivo final aprovado. Falta mover para Arte conferida.');
}
// The file the operator prepared, per item; a ready file comes ticked.
@@ -1631,7 +1638,7 @@ function finalDialog(order,ready,{replace=false}={}){
if(file){
const use=node('input');use.checked=true;use.dataset.useGenerated=index;input.required=false;drop.hidden=true;
use.onchange=()=>{drop.hidden=use.checked;input.required=!use.checked;};
slot.append(checkbox('Usar: '+file.label,use));input.generated=()=>use.checked?file.upload_id:null;
slot.append(checkbox('Usar: '+file.label,use));input.generated=()=>use.checked?file.files.map(f=>f.upload_id):null;
}
slot.append(drop);fields.push(slot);return input;
});
@@ -1644,7 +1651,7 @@ function finalDialog(order,ready,{replace=false}={}){
const refs=[];
for(const [index,input] of inputs.entries()){
const generated=input.generated?.();
if(generated){refs.push({item_index:index,upload_id:generated});continue;}
if(generated){refs.push(...generated.map(upload_id=>({item_index:index,upload_id})));continue;}
for(const file of input.files){
const uid=await dtfUpload(file,{api,startPath:'/orders/'+order.id+'/uploads',scope:'operator:'+order.id+':'+order.version,progress:text=>say(text)});
refs.push({item_index:index,upload_id:uid});
@@ -1760,7 +1767,7 @@ function orderFacts(order){
if(order.machine||board.machines?.length)grid.append(machineCard(order));
return grid;
}
const PRINT_TEXT={pending:'Na fila para gerar',rendering:'Gerando arquivo…',ready:'PDF gerado',manual:'Preparar à mão',failed:'Falhou ao gerar'};
const PRINT_TEXT={pending:'Na fila para gerar',rendering:'Gerando arquivo…',ready:'Arquivo gerado',manual:'Preparar à mão',failed:'Falhou ao gerar'};
// A line on an item: what is fine (ok), to look at (warn) or wrong (bad).
function itemNote(text,tone=''){
const line=node('div',undefined,'inote'+(tone?' '+tone:''));
@@ -1812,7 +1819,10 @@ function itemCard(order,item,index){
const links=node('div',undefined,'links');
const dl_=(text,uid)=>{const b=downloadButton(text,download(uid),'btn');return b;};
if(fix&&!fix.expired)links.append(dl_('Correção',fix.upload_id));
else if(row?.status==='ready'&&row.detail?.source!=='original')links.append(dl_('PDF',row.upload_id));
else if(row?.status==='ready'&&row.detail?.source!=='original'){
const made=generatedFiles(row);
made.forEach((f,k)=>links.append(dl_(made.length>1?'Parte '+(k+1)+' de '+made.length:/\.pdf$/i.test(f.name)?'PDF':'PNG',f.upload_id)));
}
item.uploads.forEach((uid,i)=>links.append(dl_(item.uploads.length>1?'Original '+(i+1):'Arquivo original',uid)));
if(spec?.placements){const m=button('Manifesto',()=>manifest(spec,contractionRecord(item,order.contraction?.[index])),'btn');m.prepend(svgIcon(IC.file,'i m'));links.append(m);}
if(may('produce')&&!fix&&['rec','tra'].includes(order.state)&&(!row||row.status==='manual'||row.status==='failed')){