Language binding for the libBeresta library for Janet language.
libBeresta is a free, open-source,
cross-platform library for generating PDF files.
This repository is a member of the brst-binding-<lang> family of language
bindings for the libBeresta library, intended for the Janet language.
The language bindings are automatically generated from canonical definitions presented as S-expressions in [gen/data/*.lsp][gen-data], which are updated along with the library.
- Library API is automatically generated from
gen/data/*.lsp - Build tested only on Linux
- Implemented as Janet native
- Released together with the main library
By convention adopted in the libBeresta library, each language
binding must contain two mandatory files:
- README.md – description of the language binding
- CMakeLists.txt – entry point for generating language binding files, verifying its functionality, and building a redistributable archive.
All other content is determined by the specifics of working with projects in Janet.
Clone the language binding repository:
git clone https://github.com/libBeresta/brst-binding-janet.gitBuild the library:
cd brst-binding-janet
cmake -S . -B _build -DLIBBRST_SHARED_LIB=OFF
cmake --build _buildThe _build name is important; it is used in subsequent work with the library.
Janet sources use Janet bundle to build Janet native.
Build and install the Janet bundle:
janet-pm build
janet-pm installA library containing the language binding code will be built and installed into the Janet ecosystem.
Now you can verify that everything works:
cmake --build _build --target checkor (which is the same):
janet-pm testIt should print the message
All tests passed.
You can now navigate to the demos/ folder and start running examples by calling
janet minimal.janetAfter each run, a corresponding *.pdf file should be created.
It is possible to use library as an dependency to Janet bundle.
Make project folder and folder bundle
mkdir -p prj/bundleCreate file prj/bundle/info.jdn with contents:
@{:author "Your Name"
:description "libBeresta test"
:license "MIT"
:jpm-dependencies @["spork"
{:url "https://github.com/libBeresta/brst-binding-janet.git"}
{:url "https://github.com/rwtolbert/janet-native-tools.git" :tag "0.2.0"}]
:name "brst-test"
:version "1.0.1"}
Create file prj/bundle/info.jdn with contents:
(use brst)
(with-pdf-document pdf "minimal.pdf"
(let [page (doc-page-add pdf)]
(page-setsize page
page-size-a4
page-orientation-landscape)))
Then run
cd prj
janet-pm deps
janet-pm build
There should be file minimal.pdf created. Enjoy!
The libBeresta library is under development; progress can be tracked in the repository https://github.com/libBeresta/libBeresta, as well as on the website libberesta.ru.