parse_pdf

Function parse_pdf 

Source
pub fn parse_pdf(path: &Path) -> Result<Vec<Week>, ParserError>
Expand description

Parse a Bromcom PDF timetable file.

Extracts text with coordinates from each page and reconstructs the timetable grid by detecting week boundaries, day columns, and period rows.

§Arguments

  • path - Path to the Bromcom PDF file

§Returns

A vector of Week structures, one for each week found in the PDF.

§Errors

Returns ParserError if:

  • The PDF file cannot be opened or read
  • The PDF structure is invalid
  • Text extraction fails

§Example

use timetable_core::parser::parse_pdf;
use std::path::Path;

let weeks = parse_pdf(Path::new("input/timetable.pdf"))?;
println!("Found {} weeks", weeks.len());
for week in weeks {
    println!("{}  has {} lessons", week.week_name, week.lessons.len());
}