fschutt / printpdf

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

Units #122

Closed ta-vroom closed 2 years ago

ta-vroom commented 2 years ago

Is Mm something that lopdf uses. I'm trying to switch to an all rust codebase from libharu and finding typing Mm::from(Pt) a little wordy.

Any way to make it require a float instead of Mm? Pt would be preferred. I just couldn't find it in the codebase.

fschutt commented 2 years ago

I know it's wordy, but trust me, I've run into lots of issues in C APIs where it wasn't sure whether you have to input Mm, Pt or Px depending on context (if it's just an f32). You could add more convenience wrappers, but I wouldn't change the overall design, you can use .into() conversions instead of ::from. Especially since (when manually creating PDFs), you often need to calculate a lot of offsets.