Files
OCR/openspec/changes/archive/2025-12-11-fix-ocr-track-table-rendering/tasks.md
egg cfe65158a3 feat: enable document orientation detection for scanned PDFs
- Enable PP-StructureV3's use_doc_orientation_classify feature
- Detect rotation angle from doc_preprocessor_res.angle
- Swap page dimensions (width <-> height) for 90°/270° rotations
- Output PDF now correctly displays landscape-scanned content

Also includes:
- Archive completed openspec proposals
- Add simplify-frontend-ocr-config proposal (pending)
- Code cleanup and frontend simplification

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 17:13:46 +08:00

35 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 1. Fix Table HTML Extraction
### 1.1 pp_structure_enhanced.py
- [x] 1.1.1 在 bbox overlap 匹配時L527-534添加 `pred_html` 提取邏輯
- [x] 1.1.2 確保 `element['html']` 在所有匹配路徑都被正確設置
- [x] 1.1.3 添加 `extracted_text` 從 HTML 提取純文字內容
- [x] 1.1.4 添加日誌記錄 HTML 提取狀態
## 2. Fix PDF Coordinate System
### 2.1 pdf_generator_service.py
- [x] 2.1.1 對於 OCR Track使用 OCR 座標系尺寸 (如 1275x1650) 作為 PDF 頁面尺寸
- [x] 2.1.2 修改 `_get_page_size_for_track()` 方法區分 OCR/Direct track
- [x] 2.1.3 調整字體大小計算,避免因縮放導致文字過小
- [x] 2.1.4 確保座標轉換在 OCR Track 時不進行額外縮放
## 3. Improve Table Cell Quality Check
### 3.1 pdf_generator_service.py
- [x] 3.1.1 審查 `_check_cell_boxes_quality()` 判定條件
- [x] 3.1.2 放寬或調整判定閾值,避免過度過濾有效表格 (overlap threshold 10% → 25%)
- [x] 3.1.3 添加更詳細的日誌說明為何表格被判定為 "bad quality"
### 3.2 Fix Table Content Rendering
- [x] 3.2.1 發現問題:`_draw_table_with_cell_boxes` 只渲染邊框,不渲染文字內容
- [x] 3.2.2 添加 `cell_boxes_rendered` flag 追蹤邊框是否已渲染
- [x] 3.2.3 修改邏輯cell_boxes 渲染邊框後繼續使用 ReportLab Table 渲染文字
- [x] 3.2.4 條件性跳過 GRID style 當 cell_boxes 已渲染邊框時
## 4. Testing
- [x] 4.1 使用 edit.pdf 測試修復後的 OCR Track 處理
- [x] 4.2 驗證表格 HTML 正確提取並渲染
- [x] 4.3 驗證文字大小一致且清晰可讀
- [ ] 4.4 確認其他文件類型不受影響