Implement PDF text extraction #5

Closed
opened 2026-03-28 12:48:48 +00:00 by KnallerKalle · 1 comment
KnallerKalle commented 2026-03-28 12:48:48 +00:00 (Migrated from github.com)

Context

As part of Phase 1 (Foundation), we need to implement PDF text extraction functionality to read the content from uploaded PDF files for audio conversion.

Description

Implement PDF text extraction using Rust backend and integrate it with the upload workflow.

Requirements

Backend Implementation (Rust)

  • Add pdf-extract crate to Cargo.toml
  • Implement extract_pdf_text() function
  • Handle various PDF formats and layouts
  • Preserve paragraph structure
  • Handle multi-column layouts
  • Support basic text extraction
  • OCR fallback for image-based PDFs (future enhancement)

Tauri Command

  • Create extract_pdf_text(file_path: String) command
  • Return extracted text as String
  • Proper error handling for invalid PDFs
  • Cross-platform PDF library support

Integration with Uploads

  • Update upload record in database after extraction
  • Create lesson from extracted text
  • Store extracted text in lesson content field
  • Set processing_status to "completed"

Frontend Updates

  • Update FileUpload component to trigger extraction
  • Show extraction progress
  • Create lesson after successful extraction
  • Redirect user to lesson detail view
  • Handle extraction errors gracefully

Acceptance Criteria

  • PDF text extracted successfully from uploaded files
  • Paragraph structure preserved
  • Database upload record updated with extracted text
  • Lesson created from extracted content
  • Processing status set to "completed"
  • Error handling for corrupt PDFs
  • Progress indication during extraction

Technical Approach

Dependencies

pdf-extract = "0.7"
# Or alternative: lopdf = "0.31"

Implementation

use pdf_extract;

.extract_pdf_text(file_path: String) -> Result<String, String> {
    let text = pdf_extract::extract_text_from_file(&file_path)?;
    Ok(text)
}

Database Update Flow

  1. Upload PDF → Create upload record (status: "pending")
  2. Extract text → Read PDF content
  3. Create lesson → Store extracted text
  4. Update upload → Set status: "completed", link lesson_id

Priority

High - This is Milestone 6 of Phase 1

Design Reference

See .development/docs/design-document.md section "Feature Specifications"

  • See "PDF to Audio Conversion" → "Text Extraction"

Notes

  • Text quality depends on PDF structure
  • Complex layouts may need manual editing after extraction
  • Consider adding OCR for image-based PDFs in future
  • Extracted text will be used for TTS in next milestone

Dependencies

  • Depends on: Issue #4 (PDF Upload) - Completed
  • Blocks: Issue #7 (Basic TTS Integration)
## Context As part of Phase 1 (Foundation), we need to implement PDF text extraction functionality to read the content from uploaded PDF files for audio conversion. ## Description Implement PDF text extraction using Rust backend and integrate it with the upload workflow. ## Requirements ### Backend Implementation (Rust) - Add pdf-extract crate to Cargo.toml - Implement extract_pdf_text() function - Handle various PDF formats and layouts - Preserve paragraph structure - Handle multi-column layouts - Support basic text extraction - OCR fallback for image-based PDFs (future enhancement) ### Tauri Command - Create extract_pdf_text(file_path: String) command - Return extracted text as String - Proper error handling for invalid PDFs - Cross-platform PDF library support ### Integration with Uploads - Update upload record in database after extraction - Create lesson from extracted text - Store extracted text in lesson content field - Set processing_status to "completed" ### Frontend Updates - Update FileUpload component to trigger extraction - Show extraction progress - Create lesson after successful extraction - Redirect user to lesson detail view - Handle extraction errors gracefully ## Acceptance Criteria - [ ] PDF text extracted successfully from uploaded files - [ ] Paragraph structure preserved - [ ] Database upload record updated with extracted text - [ ] Lesson created from extracted content - [ ] Processing status set to "completed" - [ ] Error handling for corrupt PDFs - [ ] Progress indication during extraction ## Technical Approach ### Dependencies ```toml pdf-extract = "0.7" # Or alternative: lopdf = "0.31" ``` ### Implementation ```rust use pdf_extract; .extract_pdf_text(file_path: String) -> Result<String, String> { let text = pdf_extract::extract_text_from_file(&file_path)?; Ok(text) } ``` ### Database Update Flow 1. Upload PDF → Create upload record (status: "pending") 2. Extract text → Read PDF content 3. Create lesson → Store extracted text 4. Update upload → Set status: "completed", link lesson_id ## Priority High - This is Milestone 6 of Phase 1 ## Design Reference See .development/docs/design-document.md section "Feature Specifications" - See "PDF to Audio Conversion" → "Text Extraction" ## Notes - Text quality depends on PDF structure - Complex layouts may need manual editing after extraction - Consider adding OCR for image-based PDFs in future - Extracted text will be used for TTS in next milestone ## Dependencies - Depends on: Issue #4 (PDF Upload) - Completed - Blocks: Issue #7 (Basic TTS Integration)
KnallerKalle commented 2026-03-28 12:53:47 +00:00 (Migrated from github.com)

Closed by commit cb8e883. All acceptance criteria met:

  • PDF text extracted successfully
  • Lesson created from extracted content
  • Upload record updated with lesson_id
  • Processing status set to completed
  • Error handling for corrupt PDFs
  • Progress indication during extraction
Closed by commit cb8e883. All acceptance criteria met: - PDF text extracted successfully - Lesson created from extracted content - Upload record updated with lesson_id - Processing status set to completed - Error handling for corrupt PDFs - Progress indication during extraction
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Kalle/ATM#5
No description provided.