# Official Letterhead and Subject Key Export Update

## Scope

The summative report exports were updated in `modules/exams/summative_reports.php` and the lightweight PDF writer in `includes/SimpleLandscapePDF.php`.

## PDF exports

Both the **Unit Summative Marksheet** and **Class Summative Average – All Units** PDFs now use the institution's saved official letterhead information:

- Republic of Kenya
- Ministry of Education
- State Department of Vocational and Technical Training
- Institution code
- Institution name
- Postal address and telephone
- Email and website
- Institution motto
- Saved left and right letterhead logos

The letterhead is repeated on every generated PDF page. The PDF writer now embeds common JPEG and PNG logos directly, without requiring Composer. If a saved logo is unavailable or unsupported, the official text letterhead still renders correctly.

## Subject key pagination

The Subject Key now appears **below the marks table on the same PDF page whenever space is available**.

- Unit marksheet: the selected `Unit Code - Unit Name` is placed below the final marks table page.
- All-units average: the key for each displayed group of unit columns is placed below the final table page for that group.
- A separate Subject Key page is created only when the remaining page space is insufficient.
- The previous unconditional duplicate Subject Key appendix was removed.

## Excel exports

Excel-compatible exports now start with the same official institutional letterhead and saved logos. The report identity, class, course, year, module, session, academic year and selected unit are displayed below the letterhead.

The Subject Key is placed immediately after the marks table and marked to avoid an unnecessary page break when the worksheet is printed.

## Validation

- 168 PHP files passed syntax validation.
- JPEG and PNG logo embedding was tested in a valid PDF 1.4 document.
- The landscape letterhead, 16 report rows and a six-unit Subject Key were rendered on one A4 landscape page without clipping.
- No database migration is required.
