#ffi #libre-office-kit #lok

libreoffice-rs

Rust binding for LibreOfficeKit

9 releases

0.3.3 Apr 14, 2023
0.3.2 Jul 3, 2022
0.3.0 Jun 24, 2022
0.2.1 Jun 23, 2022
0.1.2 May 26, 2022

#302 in #ffi

Download history 2/week @ 2023-12-11 9/week @ 2024-01-01 6/week @ 2024-01-08 54/week @ 2024-02-19 15/week @ 2024-02-26 10/week @ 2024-03-11 15/week @ 2024-03-18 27/week @ 2024-03-25

53 downloads per month

Apache-2.0

31KB
326 lines

libreofficeKit-rs

Rust bindings to LibreOfficeKit

Installation

[dependencies]
libreoffice-rs = 0.3

you need install LibreOffice ( >= 6.0 is recommended ), Debian 11 for example:

$ sudo apt-get install libreoffice libreofficekit-dev clang
# set env variable `LO_INCLUDE_PATH` to the LibreOffice headers.
$ export LO_INCLUDE_PATH=/usr/include/LibreOfficeKit

due to this issue , here use a libwrapper.a to carry static funtion lok_init which defined in LibreOfficeKitInit.h.

Example

use libreoffice_rs::{Office, LibreOfficeKitOptionalFeatures, urls};

fn main() -> Result<(), Box<dyn std::error::Error>> {
  // your libreoffice installation path
  let mut office = Office::new("/usr/lib/libreoffice/program")?;
  let doc_url = urls::local_into_abs("./test_data/test.odt")?;
  let mut doc = office.document_load(doc_url)?;
  doc.save_as("/tmp/test.pdf", "pdf", None);
  Ok(())
}

License

This project is licensed under the [Apache License 2.0][license]

Dependencies

~1.4–3.5MB
~96K SLoC