Skip to content

Commit

Permalink
Fix issue #86 by upgrade to MuPDF 1.24.4 (#97)
Browse files Browse the repository at this point in the history
Co-authored-by: vincent <[email protected]>
  • Loading branch information
vinxv and vincent authored Dec 1, 2024
1 parent dc6eef7 commit 5f80b51
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
7 changes: 7 additions & 0 deletions mupdf-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ fn build_libmupdf() {
profile
);
}

if profile == "Debug" {
println!("cargo:rustc-link-lib=dylib=ucrtd");
println!("cargo:rustc-link-lib=dylib=vcruntimed");
println!("cargo:rustc-link-lib=dylib=msvcrtd");
}

println!("cargo:rustc-link-lib=dylib=libmupdf");
println!("cargo:rustc-link-lib=dylib=libthirdparty");
} else {
Expand Down
2 changes: 1 addition & 1 deletion mupdf-sys/mupdf
Submodule mupdf updated 691 files
2 changes: 1 addition & 1 deletion mupdf-sys/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -3012,7 +3012,7 @@ void mupdf_pdf_page_set_crop_box(fz_context *ctx, pdf_page *page, fz_rect rect,
{
fz_try(ctx)
{
fz_rect mediabox = pdf_bound_page(ctx, page);
fz_rect mediabox = pdf_bound_page(ctx, page, FZ_MEDIA_BOX);
pdf_obj *obj = pdf_dict_get_inheritable(ctx, page->obj, PDF_NAME(MediaBox));
if (obj)
{
Expand Down
Binary file added tests/files/utf8-error-on-this-file.pdf
Binary file not shown.
18 changes: 18 additions & 0 deletions tests/test_issues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,21 @@ fn test_issue_60_display_list() {
})
.collect();
}

#[test]
fn test_issue_86_invalid_utf8() {
let doc = PdfDocument::open("tests/files/utf8-error-on-this-file.pdf").unwrap();
for (idx, page) in doc.pages().unwrap().enumerate() {
let page = page.unwrap();
let text = page.to_text();
assert!(text.is_ok());
println!("page: {idx}, text: {}", text.unwrap());

let json = page.stext_page_as_json_from_page(1.0);
assert!(json.is_ok());

// Validate JSON parsing
let parsed_json: Result<serde_json::Value, _> = serde_json::from_str(&json.unwrap());
assert!(parsed_json.is_ok());
}
}

0 comments on commit 5f80b51

Please sign in to comment.