Last fix kept signatures intact but the landscape BoL still overflowed to a second page (with the signature row pushed entirely to page 2). The real ask was for the landscape variant to fit on one page since landscape has plenty of vertical room. Aggressive landscape compaction: - Body font 11pt → 10pt, td font 10 → 9.5pt, th font 10 → 9pt - Cell padding 8/10px → 4/8px - Table margin-bottom 12px → 6px - h2 title 26pt → 18pt with tighter top/bottom margins - BoL # subtitle 14pt → 11pt - Shipper/consignee row height 120 → 70px - highlight-box (cert) padding 10px → 6/10, font 10 → 9pt - sig-box padding 12 → 8/10px - sig-line height 70 → 45px Verified with pypdf: landscape BoL now renders as exactly 1 page with cert + all 3 signature labels + company info all present. 137 KB clean PDF. Portrait variant left untouched (it already fit on one page and the bigger title is appropriate for portrait). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
env = env # noqa
|
|
import re, subprocess, tempfile, os
|
|
rep = env.ref('fusion_plating_reports.action_report_fp_bol_landscape')
|
|
dlv = env['fusion.plating.delivery'].search([], order='id desc', limit=1)
|
|
html, _ = rep.with_context(force_report_rendering=True
|
|
)._render_qweb_html(rep.report_name, [dlv.id])
|
|
out = html.decode() if isinstance(html, bytes) else str(html)
|
|
# Strip styles/scripts and just count visible text length per major block
|
|
def find_block(label, txt):
|
|
i = txt.find(label)
|
|
if i < 0: return None
|
|
return txt[i:i+200]
|
|
print('=== blocks present ===')
|
|
for label in ['BILL OF LADING','BoL #','SHIPPER','SHIP DATE','CARGO DESCRIPTION',
|
|
'CoC','PACKING LIST','is to certify','Shipper (Signature']:
|
|
print(f' {label!r}:', 'found' if label in out else 'MISSING')
|
|
|
|
# Render PDF, save, and count pages
|
|
pdf, _ = rep.with_context(force_report_rendering=True
|
|
)._render_qweb_pdf(rep.report_name, [dlv.id])
|
|
path = '/tmp/bol_landscape.pdf'
|
|
with open(path, 'wb') as f: f.write(pdf)
|
|
print(f'\nPDF: {len(pdf)/1024:.1f} KB at {path}')
|
|
n = len(re.findall(rb'/Type\s*/Page[^s]', pdf))
|
|
print(f'pages: {n}')
|