# result-export Spec Delta

## MODIFIED Requirements

### Requirement: Enhanced PDF Export with Layout Preservation
The PDF export SHALL accurately preserve document layout from both OCR and direct extraction tracks with correct coordinate transformation and multi-page support.

#### Scenario: Export PDF from direct extraction track
- **WHEN** exporting PDF from a direct-extraction processed document
- **THEN** the PDF SHALL maintain exact text positioning from source
- **AND** preserve original fonts and styles where possible
- **AND** include extracted images at correct positions

#### Scenario: Export PDF from OCR track with full structure
- **WHEN** exporting PDF from OCR-processed document
- **THEN** the PDF SHALL use all 23 PP-StructureV3 element types
- **AND** render tables with proper cell boundaries
- **AND** maintain reading order from parsing_res_list

#### Scenario: Handle coordinate transformations correctly
- **WHEN** generating PDF from UnifiedDocument
- **THEN** system SHALL use explicit page dimensions from OCR results (not inferred from bounding boxes)
- **AND** correctly transform Y-axis coordinates from top-left (OCR) to bottom-left (PDF/ReportLab) origin
- **AND** prevent vertical flipping or position misalignment errors
- **AND** handle page size variations accurately

#### Scenario: Support multi-page documents with varying dimensions
- **WHEN** generating PDF from multi-page document with mixed orientations
- **THEN** system SHALL apply correct page size for each page independently
- **AND** support both portrait and landscape pages in same document
- **AND** NOT use first page dimensions for all subsequent pages
- **AND** call setPageSize() for each new page before rendering content

#### Scenario: Single-page layout verification
- **WHEN** user exports OCR-processed single-page document (e.g., img1.png)
- **THEN** generated PDF text positions SHALL match original image coordinates
- **AND** top-aligned text (e.g., headers) SHALL appear at correct vertical position
- **AND** no content SHALL be vertically flipped or offset from expected position
