diff --git a/mupdf-sys/build.rs b/mupdf-sys/build.rs index d396973..6e918c2 100644 --- a/mupdf-sys/build.rs +++ b/mupdf-sys/build.rs @@ -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 { diff --git a/mupdf-sys/mupdf b/mupdf-sys/mupdf index e32a0e2..31b25c5 160000 --- a/mupdf-sys/mupdf +++ b/mupdf-sys/mupdf @@ -1 +1 @@ -Subproject commit e32a0e27163cccc98eb4b509ea1493cdac8b4930 +Subproject commit 31b25c586c2db808a0817dd785c9f56243581255 diff --git a/mupdf-sys/wrapper.c b/mupdf-sys/wrapper.c index 5ce5a28..1d848a5 100644 --- a/mupdf-sys/wrapper.c +++ b/mupdf-sys/wrapper.c @@ -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) { diff --git a/tests/files/utf8-error-on-this-file.pdf b/tests/files/utf8-error-on-this-file.pdf new file mode 100644 index 0000000..b06d779 Binary files /dev/null and b/tests/files/utf8-error-on-this-file.pdf differ diff --git a/tests/test_issues.rs b/tests/test_issues.rs index 00ceab7..c99610f 100644 --- a/tests/test_issues.rs +++ b/tests/test_issues.rs @@ -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::from_str(&json.unwrap()); + assert!(parsed_json.is_ok()); + } +}