J-F-Liu / lopdf

A Rust library for PDF document manipulation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid cross-reference table (could not parse xref)

pheianox opened this issue · comments

fn shrink_file(path: &str) {
  let doc = Document::load(path);
  match doc {
    Ok(mut pdf) => {
      pdf.compress();
      pdf.save(format!("{path}__compressed")).unwrap();
    },
    Err(error) => {
      panic!("error {}", error.to_string())
    }
  };
  
}

Output

thread 'main' panicked at 'error Invalid cross-reference table (could not parse xref)', src/main.rs:36:7
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
 ELIFECYCLE  Command failed.
 ELIFECYCLE  Command failed with exit code 101.

What's the problem?

can you provide the pdf you tried to open so that we can examine it.

can you provide the pdf you tried to open so that we can examine it.

The file is gone :(

Maybe problem was that I created it in Figma... idk