# result-export Specification

## Purpose
TBD - created by archiving change fix-v2-api-ui-issues. Update Purpose after archive.
## Requirements
### Requirement: Export Interface
The Export page SHALL support downloading OCR results in multiple formats using V2 task APIs.

#### Scenario: Export page uses V2 download endpoints
- **WHEN** user selects a format and clicks export button
- **THEN** frontend SHALL call V2 endpoint `/api/v2/tasks/{task_id}/download/{format}`
- **AND** frontend SHALL NOT call V1 `/api/v2/export` endpoint (which returns 404)
- **AND** file SHALL download successfully

#### Scenario: Export supports multiple formats
- **WHEN** user exports a completed task
- **THEN** system SHALL support downloading as TXT, JSON, Excel, Markdown, and PDF
- **AND** each format SHALL use correct V2 download endpoint
- **AND** downloaded files SHALL contain task OCR results

### Requirement: Multi-Task Export Selection
The Export page SHALL allow users to select and export multiple tasks.

#### Scenario: Select multiple tasks for export
- **WHEN** Export page loads
- **THEN** page SHALL display list of user's completed tasks
- **AND** page SHALL provide checkboxes to select multiple tasks
- **AND** page SHALL NOT require batch ID from upload store (legacy V1 behavior)

#### Scenario: Export selected tasks
- **WHEN** user selects multiple tasks and clicks export
- **THEN** system SHALL download each selected task's results in chosen format
- **AND** downloaded files SHALL be named distinctly (e.g., `{task_id}_result.{ext}`)
- **AND** system MAY provide option to download as ZIP archive for multiple files

### Requirement: Export Configuration Persistence
Export settings (format, thresholds, templates) SHALL apply consistently to V2 task downloads.

#### Scenario: Apply confidence threshold to export
- **WHEN** user sets confidence threshold to 0.7 and exports
- **THEN** downloaded results SHALL only include OCR text with confidence >= 0.7
- **AND** threshold SHALL apply via V2 download endpoint query parameters

#### Scenario: Apply CSS template to PDF export
- **WHEN** user selects CSS template for PDF format
- **THEN** downloaded PDF SHALL use selected styling
- **AND** template SHALL be passed to V2 `/tasks/{id}/download/pdf` endpoint

