Back to blog
March 12, 202611 min read

Building Multi-Page PDF Reports with Headers, Footers, and Page Numbers

Use @page CSS rules, page counters, and the compose API to build professional multi-section reports with running headers.

reportsmulti-pageheaders-footerspage-numbers

Building multi-section reports

Business reports often need multiple sections with different layouts: a cover page, table of contents, data tables, charts, and an appendix. pdfRelay's compose API handles this elegantly.

The compose API

const res = await fetch('https://pdfrelay.com/api/v1/compose', {
  method: 'POST',
  headers: { 'Authorization': 'Bearer sk_live_...', 'Content-Type': 'application/json' },
  body: JSON.stringify({
    parts: [
      { template: 'report-cover', data: { title: 'Q1 Report', date: '2026' } },
      { html: '<h2>Executive Summary</h2><p>Key findings...</p>' },
      { template: 'financial-table', data: { rows: financialData } },
      { html: appendixHtml },
    ],
    options: { page_size: 'Letter' },
  }),
});

Each part can be a template with data OR raw HTML. Parts are joined with automatic page breaks.

Running headers and footers

@page {
  @bottom-center {
    content: "Page " counter(page) " of " counter(pages);
    font-size: 9pt;
    color: #999;
  }
  @top-right {
    content: "Q1 2026 Report — Confidential";
    font-size: 8pt;
  }
}

Standard CSS @page rules. The same syntax you'd use for print stylesheets in a browser. No proprietary template language, no learning curve — just HTML and CSS.

Ready to try pdfRelay?

Get started free. No credit card required.