env = env # noqa import re for variant in ('portrait', 'landscape'): rep = env.ref(f'fusion_plating_reports.action_report_fp_bol_{variant}') dlv = env['fusion.plating.delivery'].search([], order='id desc', limit=1) pdf, _ = rep.with_context(force_report_rendering=True )._render_qweb_pdf(rep.report_name, [dlv.id]) # Count pages by looking at the /Type /Page (not /Pages) markers n_pages = len(re.findall(rb'/Type\s*/Page[^s]', pdf)) print(f'{variant:10s} {len(pdf)/1024:6.1f} KB pages={n_pages}')