fschutt / printpdf

A fully-featured PDF library for Rust, WASM-ready
https://fschutt.github.io/printpdf/
MIT License
829 stars 98 forks source link

Error building as wasm32-wasi target #175

Closed ashokspeelyaal closed 3 months ago

ashokspeelyaal commented 7 months ago

I have printpdf = "0.7.0" in my Cargo.toml

If I run my Rust binary independently, there are no issues. However, we are building all our services as wasm32-wasi targets.

When I run

cargo build --target wasm32-wasi

I get this issue: Note: I tried adding time = "0.3.34" as well.

Compiling printpdf v0.7.0 error[E0432]: unresolved importcrate::OffsetDateTime` --> //.cargo/registry/src/index.crates.io-6f17d22bba15001f/printpdf-0.7.0/src/document_info.rs:3:5 3 use crate::OffsetDateTime; ^^^^^^^^^^^^^^^^^^^^^ no OffsetDateTime in the root

help: consider importing this struct instead | 3 | use time::OffsetDateTime; | ~~~~

error[E0432]: unresolved import crate::OffsetDateTime --> //.cargo/registry/src/index.crates.io-6f17d22bba15001f/printpdf-0.7.0/src/pdf_document.rs:10:5 10 use crate::OffsetDateTime; ^^^^^^^^^^^^^^^^^^^^^ no OffsetDateTime in the root

help: consider importing this struct instead | 10 | use time::OffsetDateTime; | ~~~~

error[E0432]: unresolved import crate::OffsetDateTime --> //.cargo/registry/src/index.crates.io-6f17d22bba15001f/printpdf-0.7.0/src/pdf_metadata.rs:3:5 3 use crate::OffsetDateTime; ^^^^^^^^^^^^^^^^^^^^^ no OffsetDateTime in the root

help: consider importing this struct instead | 3 | use time::OffsetDateTime; | ~~~~

error[E0432]: unresolved import crate::OffsetDateTime --> //.cargo/registry/src/index.crates.io-6f17d22bba15001f/printpdf-0.7.0/src/xmp_metadata.rs:3:5 3 use crate::OffsetDateTime; ^^^^^^^^^^^^^^^^^^^^^ no OffsetDateTime in the root

help: consider importing this struct instead | 3 | use time::OffsetDateTime; | ~~~~

error[E0432]: unresolved import crate::OffsetDateTime --> //.cargo/registry/src/index.crates.io-6f17d22bba15001f/printpdf-0.7.0/src/xobject.rs:4:5 4 use crate::OffsetDateTime; ^^^^^^^^^^^^^^^^^^^^^ no OffsetDateTime in the root

help: consider importing this struct instead | 4 | use time::OffsetDateTime; | ~~~~

For more information about this error, try rustc --explain E0432. error: could not compile printpdf (lib) due to 5 previous errors `

fschutt commented 7 months ago

This was fixed in https://github.com/fschutt/printpdf/commit/3fb349f82f02888ad5afaef9745e1f7c78c1187a use master

fschutt commented 3 months ago

WASM is fully supported now.