Infrastructure medium complexity backend
0
Dependencies
0
Dependents
0
Entities
1
Integrations

Description

Generates a human-readable PDF version of the Bufdir export, formatted according to Bufdir's report template. The PDF is intended for manual submission scenarios and internal review before the file-based export is sent.

Feature: Bufdir Reporting & Export

bufdir-pdf-generator

Summaries

The Bufdir PDF Report Generator provides organisations with a human-readable version of their Bufdir submission, enabling internal review, sign-off, and archival before the machine-readable file is dispatched to the agency. This is critical for governance: coordinators and managers can visually verify data accuracy in a professionally formatted document bearing the organisation's logo and reporting period before any submission occurs. For organisations where manual submission workflows remain in use, the PDF also serves as the direct submission artefact. By producing audit-ready, consistently formatted reports automatically, the platform reduces the review effort per reporting cycle and supports internal accountability without requiring additional tooling or manual document assembly by staff.

Medium complexity backend component built in Dart, dependent on the same MappedRow pipeline as the Excel/CSV generator. Additional dependency is the BufdirReportTemplate definition, which must be designed and signed off by stakeholders before implementation begins — template layout decisions (table structure, header placement, summary statistics) are a design risk that should be resolved in an early sprint. The component must handle variable-length datasets (few rows to hundreds), so page overflow and continuation table rendering must be explicitly tested. getPageCount() is needed by the bundling layer for attachment metadata.

Coordination with the Export File Storage Adapter is required for byte handoff. Testing should include multi-page exports and logo rendering across different org configurations. Low deployment risk as it is a pure backend computation with no external service calls.

Backend Dart component with interfaces generatePdf(), applyTemplate(), getFileBytes(), and getPageCount(). It receives List and ExportMetadata, then applies a BufdirReportTemplate to a PdfDocument instance using a Dart PDF library (e.g., pdf package). The template system must support configurable table column layouts, header/footer injection with organisation logo bytes and reporting period text, and auto-pagination for large datasets. applyTemplate() should be a pure transformation — separating template logic from data binding enables unit testing of layout rules independently.

getFileBytes() serialises the completed document to Uint8List for handoff to the storage adapter. getPageCount() is called post-render. Watch for memory pressure on very large datasets; consider streaming page generation if row counts exceed ~500. No external network calls — fully synchronous computation.

Responsibilities

  • Render mapped Bufdir data into a formatted PDF document
  • Apply Bufdir report template layout (headers, tables, summary statistics)
  • Include organisation logo, reporting period, and page numbering
  • Return PDF as byte stream for download or attachment bundling

Interfaces

generatePdf(List<MappedRow> rows, ExportMetadata metadata)
applyTemplate(PdfDocument doc, BufdirReportTemplate template)
getFileBytes()
getPageCount()

Used Integrations (1)

External integrations and APIs this component relies on

API Contract

View full contract →
REST /api/v1/bufdir-pdf 3 endpoints
POST /api/v1/bufdir-pdf Generate a PDF report from mapped rows
GET /api/v1/bufdir-pdf/:export_id/download Download generated PDF bytes
GET /api/v1/bufdir-pdf/:export_id/info Get PDF metadata (page count, size) without downloading