ajrcarey / pdfium-render

A high-level idiomatic Rust wrapper around Pdfium, the C++ PDF library used by the Google Chromium project.
https://crates.io/crates/pdfium-render
Other
341 stars 52 forks source link

Ver. `0.8.13` compiling `error[E0308]: mismatched types` #113

Closed boan-anbo closed 11 months ago

boan-anbo commented 11 months ago

Somehow I could not build Pdfium 0.8.13.

Downgrade to "pdfium-render = "=0.8.12" or applying the suggested try_into() can fix the issue. A PR is submitted.

error[E0308]: mismatched types
    --> C:\Users\User\.cargo\registry\src\index.crates.io-6f17d22bba15001f\pdfium-render-0.8.13\src\page_text.rs:411:17
     |
408  |             self.bindings.FPDFText_FindStart(
     |                           ------------------ arguments to this method are incorrect
...
411  |                 options.as_pdfium(),
     |                 ^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
     |
note: method defined here
    --> C:\Users\User\.cargo\registry\src\index.crates.io-6f17d22bba15001f\pdfium-render-0.8.13\src\bindings.rs:1467:8
     |
1467 |     fn FPDFText_FindStart(
     |        ^^^^^^^^^^^^^^^^^^
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
     |
411  |                 options.as_pdfium().try_into().unwrap(),
     |                                    ++++++++++++++++++++

https://github.com/ajrcarey/pdfium-render/blame/1f9b37a453a4cb0c3af66f84b8e07039512d19d6/src/page_text.rs#L411

My toolchain is

stable-x86_64-pc-windows-msvc (default)
rustc 1.73.0 (cc66ad468 2023-10-03)
ajrcarey commented 11 months ago

Hi @boan-anbo , thank you for reporting the issue. It must be specific to building on Windows, as the problem does not occur on MacOS or Linux.

Thank you for your pull request. I believe it's simpler just to cast to a c_ulong in PdfSearchOptions::as_pdfium(), so I've pushed a patch that does that. If you could confirm this resolves the problem, I will make a new release.

boan-anbo commented 11 months ago

Just tried 0.8.14, it's compiling. Thanks so much for taking care of this promptly!

ajrcarey commented 11 months ago

No problem, released as crate version 0.8.14.