Skip to content

Commit 044a616

Browse files
committed
Update libharu version to 1.0.1 and reflect changes in Cargo.toml and Cargo.lock files. Add libharu version printing functionality.
1 parent 03eadc9 commit 044a616

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
version = "1.0.0"
2+
version = "1.0.1"
33

44
name = "libharu_ng"
55
description = "Easily generate PDFs from your Rust app!"

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Using `libharu_ng`, you can easily create PDF documents from Rust code.
1414

1515
So, until there are mature pure-Rust alternatives for generating PDFs, `libharu_ng` is a good choice for generating PDFs from Rust code without having to use a headless browser or a commercial solution.
1616

17+
## `libharu` Version
18+
19+
This crate uses the latest version of `libharu` (2.4.4) and will be updated to the latest version of `libharu` as soon as possible.
20+
1721
## Features
1822

1923
### Standard libharu Features

examples/hello_world.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
use libharu_ng::prelude::*;
1+
use libharu_ng::{libharu_version, prelude::*};
22

33
/// Hello World example.
44
///
55
/// This example will create a new PDF file named `hello_world.pdf` in the current directory.
66
///
77
88
fn main() -> Result<(), HaruError> {
9+
println!("libharu version: {}", libharu_version());
10+
911
let doc = PdfDocument::new();
1012
let fnt = doc.get_font("Helvetica", None)?;
1113

src/lib.rs

+22
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,25 @@ impl From<haru_bindings::HPDF_Box> for HpdfBox {
6868
}
6969
}
7070
}
71+
72+
/// Returns the version of the libharu library.
73+
/// The version is a string in the format "major.minor.patch".
74+
///
75+
pub fn libharu_version() -> String {
76+
let version = unsafe { haru_bindings::HPDF_GetVersion() };
77+
let version = unsafe { std::ffi::CStr::from_ptr(version) };
78+
version.to_str().unwrap().to_string()
79+
}
80+
81+
/// Test which prints the version.
82+
///
83+
#[cfg(test)]
84+
mod tests {
85+
use super::*;
86+
87+
#[test]
88+
fn test_libharu_version() {
89+
let version = libharu_version();
90+
println!("libharu version: {}", version);
91+
}
92+
}

0 commit comments

Comments
 (0)