Skip to content
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
de689a3
Add initial OCR support
yveszoundi Apr 28, 2025
1f9b2ce
Try enabling tesseract by default
yveszoundi Apr 28, 2025
3347da7
Add flag for non windows target
yveszoundi Apr 28, 2025
8e810f6
Add flag for non windows target
yveszoundi Apr 28, 2025
fb8a9ef
CI test fix
yveszoundi Apr 28, 2025
fc23493
CI test fix
yveszoundi Apr 28, 2025
dd81df4
CI test fix
yveszoundi Apr 28, 2025
25509bc
CI test fix
yveszoundi Apr 28, 2025
c17336a
CI testing
yveszoundi May 1, 2025
c1944e2
CI testing
yveszoundi May 1, 2025
874df07
CI testing
yveszoundi May 1, 2025
2336e58
CI testing
yveszoundi May 1, 2025
2f92b06
Fix typo
yveszoundi May 1, 2025
867f633
Use only neon instructions on arm64
yveszoundi May 1, 2025
5f1c89c
Update package list for MSYS2 tests
yveszoundi May 1, 2025
6451bec
Disable neon CPU flags in build.rs
yveszoundi May 1, 2025
967e82e
CI disable some flags on windows
yveszoundi May 1, 2025
164f675
CI issues on Windows
yveszoundi May 1, 2025
4f545bc
Use FilePath type in document_writer
yveszoundi May 3, 2025
6945e23
Fix formatting with rustfmt
yveszoundi May 3, 2025
52ab73b
Conditionally enable neon flags for aarch64
yveszoundi May 3, 2025
0a5c906
Fix formatting with rustfmt
yveszoundi May 3, 2025
7886ce5
Different approach for neon flags on aarch64
yveszoundi May 3, 2025
2b5d5ac
Silence warnings in build.rs
yveszoundi May 3, 2025
0db65ff
Re-disable CPU neon flags
yveszoundi May 3, 2025
d1d5e0d
Try re-enabling neon CPU flags
yveszoundi May 4, 2025
62420f8
Try re-enabling neon CPU flags
yveszoundi May 4, 2025
9f4e5d1
Try re-enabling neon CPU flags
yveszoundi May 4, 2025
597f8f6
Retry approach for neon CPU flags
yveszoundi May 4, 2025
d914601
Fix conflicts
yveszoundi May 7, 2025
497974a
Fix conflicts
yveszoundi May 7, 2025
24da27c
Fix conflicts
yveszoundi May 7, 2025
489239c
Fix conflicts
yveszoundi May 1, 2025
901d88b
Fix conflicts
yveszoundi May 7, 2025
34dbf61
Fix conflicts
yveszoundi May 7, 2025
dd66e6c
Address conflicts
yveszoundi May 7, 2025
daf4457
Address conflicts
yveszoundi May 7, 2025
1124beb
Address conflicts
yveszoundi May 7, 2025
dabacc2
Merge branch 'main' into yveszoundi/new_pdfocr_writer
yveszoundi May 7, 2025
e6dbf1f
Try fixing timeouts for windows-2019 tests
yveszoundi May 7, 2025
0f8153e
Increase timeout for windows-2019 tests
yveszoundi May 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
submodules: "recursive"
fetch-depth: 500
- uses: dtolnay/rust-toolchain@stable
- run: sudo apt-get -y install libfontconfig1-dev
- run: sudo apt update && sudo apt-get -y install libfontconfig1-dev libc++abi-dev clang gcc g++
if: matrix.os == 'ubuntu-latest'
- name: Install LLVM
if: matrix.os == 'windows-2019'
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
install: mingw-w64-${{matrix.env}}-rust mingw-w64-${{matrix.env}}-clang base base-devel unzip git
install: mingw-w64-${{matrix.env}}-rust mingw-w64-${{matrix.env}}-clang base base-devel unzip git python3

- uses: actions/checkout@v3
with:
Expand All @@ -95,7 +95,7 @@ jobs:
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- run: sudo apt-get -y install libfontconfig1-dev
- run: sudo apt update && sudo apt-get -y install libfontconfig1-dev libc++abi-dev clang gcc g++
- name: cargo test --features serde
run: |
cargo test -Zbuild-std --target x86_64-unknown-linux-gnu --features serde
Expand All @@ -113,7 +113,7 @@ jobs:
fetch-depth: 500
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@valgrind
- run: sudo apt-get -y install libfontconfig1-dev
- run: sudo apt update && sudo apt-get -y install libfontconfig1-dev libc++abi-dev clang gcc g++
- run: cargo test --features serde
env:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: "valgrind --error-exitcode=1 --track-origins=yes"
Expand Down
17 changes: 14 additions & 3 deletions mupdf-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const CPU_FLAGS: &[(&str, &str, &str, Option<&str>)] = &[
("avx", "-mavx", "HAVE_AVX", None),
("avx2", "-mavx2", "HAVE_AVX2", None),
("fma", "-mfma", "HAVE_FMA", None),
("neon", "-mfpu=neon", "HAVE_NEON", Some("ARCH_HAS_NEON")),
//("neon", "-mfpu=neon", "HAVE_NEON", Some("ARCH_HAS_NEON")),
];

#[cfg(not(target_env = "msvc"))]
Expand Down Expand Up @@ -99,14 +99,15 @@ fn build_libmupdf() {
"libs".to_owned(),
format!("build={}", profile),
format!("OUT={}", &build_dir_str),
#[cfg(not(feature = "tesseract"))]
"USE_TESSERACT=no".to_owned(),
#[cfg(feature = "tesseract")]
"USE_TESSERACT=yes".to_owned(),
#[cfg(not(feature = "libarchive"))]
"USE_LIBARCHIVE=no".to_owned(),
#[cfg(not(feature = "zxingcpp"))]
"USE_ZXINGCPP=no".to_owned(),
#[cfg(feature = "sys-lib")]
"USE_SYSTEM_LIBS=yes".to_owned(),
"USE_ARGUMENT_FILE=yes".to_owned(),
"HAVE_X11=no".to_owned(),
"HAVE_GLUT=no".to_owned(),
"HAVE_CURL=no".to_owned(),
Expand Down Expand Up @@ -513,6 +514,16 @@ fn main() {
println!("cargo:rerun-if-changed=wrapper.h");
println!("cargo:rerun-if-changed=wrapper.c");

if let Ok(ref target_os) = env::var("CARGO_CFG_TARGET_OS") {
if target_os != "windows" {
if target_os == "macos" {
println!("cargo:rustc-link-lib=c++");
} else {
println!("cargo:rustc-link-lib=stdc++");
}
}
}

build_libmupdf();

let mut build = cc::Build::new();
Expand Down
14 changes: 14 additions & 0 deletions mupdf-sys/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -3227,6 +3227,20 @@ fz_document_writer *mupdf_new_document_writer(fz_context *ctx, const char *filen
return writer;
}

fz_document_writer *mupdf_new_pdfocr_writer(fz_context *ctx, const char *path, const char *options, mupdf_error_t **errptr)
{
fz_document_writer *writer = NULL;
fz_try(ctx)
{
writer = fz_new_pdfocr_writer(ctx, path, options);
}
fz_catch(ctx)
{
mupdf_save_error(ctx, errptr);
}
return writer;
}

fz_device *mupdf_document_writer_begin_page(fz_context *ctx, fz_document_writer *writer, fz_rect mediabox, mupdf_error_t **errptr)
{
fz_device *device = NULL;
Expand Down
15 changes: 15 additions & 0 deletions src/document_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ impl DocumentWriter {
.map(|inner| Self { inner })
}

#[cfg(feature = "tesseract")]
pub fn new_pdfocr_writer(path: &str, options: &str) -> Result<Self, Error> {
let c_path = CString::new(path)?;
let c_options = CString::new(options)?;

unsafe {
ffi_try!(mupdf_new_pdfocr_writer(
context(),
c_path.as_ptr(),
c_options.as_ptr()
))
}
.map(|inner| Self { inner })
}

pub fn begin_page(&mut self, media_box: Rect) -> Result<Device, Error> {
unsafe {
ffi_try!(mupdf_document_writer_begin_page(
Expand Down
Loading