Files
OCR/openspec/changes/improve-translated-text-fitting/tasks.md
egg 08adf3d01d feat: add translated PDF format selection (layout/reflow)
- Add generate_translated_layout_pdf() method for layout-preserving translated PDFs
- Add generate_translated_pdf() method for reflow translated PDFs
- Update translate router to accept format parameter (layout/reflow)
- Update frontend with dropdown to select translated PDF format
- Fix reflow PDF table cell extraction from content dict
- Add embedded images handling in reflow PDF tables
- Archive improve-translated-text-fitting openspec proposal

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 10:10:28 +08:00

1.4 KiB

1. Backend Implementation

  • 1.1 Create generate_reflow_pdf() method in pdf_generator_service.py
  • 1.2 Implement _get_elements_in_reading_order() for both tracks
  • 1.3 Implement reflow text rendering with consistent font sizes
  • 1.4 Implement table rendering in reflow mode (Platypus Table)
  • 1.5 Implement inline image embedding
  • 1.6 Add format=reflow query parameter to tasks download endpoint
  • 1.7 Update generate_translated_pdf() to use reflow mode

2. Frontend Implementation

  • 2.1 Add "Download Reflow PDF" button for original documents
  • 2.2 Update download logic to support format parameter
  • 2.3 Remove MADLAD-400 badge (line 545)
  • 2.4 Update translation description text to reflect Dify cloud service (line 652)

3. Testing

  • 3.1 Test OCR track reflow PDF (with reading_order) - Basic smoke test passed
  • 3.2 Test Direct track reflow PDF (implicit order) - No test data available
  • 3.3 Test translated PDF (reflow mode) - Basic smoke test passed
  • 3.4 Test documents with tables - SUCCESS (62294 bytes, 2 tables)
  • 3.5 Test documents with images - SUCCESS (embedded img_in_table)
  • 3.6 Test multi-page documents - SUCCESS (11451 bytes, 3 pages)
  • 3.7 Verify layout PDF still works correctly - SUCCESS (104543 bytes)

4. Documentation

  • 4.1 Update spec with reflow layout requirements