Skip to content

Commit

Permalink
Print explicit MuPDF Fitz error
Browse files Browse the repository at this point in the history
  • Loading branch information
randomnoise committed Sep 7, 2024
1 parent a6bf892 commit 13de4b7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/core/src/document/pdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,16 @@ impl Document for PdfDocument {
}

fn pages_count(&self) -> usize {
unsafe { mp_count_pages(self.ctx.0, self.doc) as usize }
unsafe {
let page_count: i32 = mp_count_pages(self.ctx.0, self.doc);

if page_count <= 0 {
eprintln!("Error: MuPDF Fitz count_pages function returned {}.", page_count);
return 0;
}

return page_count as usize;
}
}

fn resolve_location(&mut self, loc: Location) -> Option<usize> {
Expand Down

0 comments on commit 13de4b7

Please sign in to comment.