Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Installation

There are three ways to install it, depending on how you plan to use it.

UsageWhat you install
Run the HTTP server as a long-lived processThe Docker image ghcr.io/waka/sghtmltopdf
Use it from Ruby or RailsThe sghtmltopdf gem
Convert from your own command lineThe sghtmltopdf binary, built from source

Plain binaries, as a tarball on GitHub Releases or through Homebrew, are not distributed. The server ships inside the image, and the FFI path ships inside the gem, so each already carries what it needs. To try the CLI locally, build from source as shown below.

Docker

docker pull ghcr.io/waka/sghtmltopdf:latest
docker run --rm -p 8080:8080 ghcr.io/waka/sghtmltopdf

Japanese fonts (BIZ UDPGothic and BIZ UDPMincho) are bundled, so Japanese PDFs come out without supplying a font yourself. See Docker for details.

Building from source

All you need is the stable Rust toolchain. There are no C libraries or system packages to install.

git clone https://github.com/waka/sghtmltopdf.git
cd sghtmltopdf
cargo build --release

The binary is written to target/release/sghtmltopdf. Put it somewhere on your PATH, or call it where it is.

./target/release/sghtmltopdf --version

If you do not need the HTTP server mode, you can drop that feature and get a smaller binary.

cargo build --release --no-default-features --features cli

Ruby / Rails

# Gemfile
gem "sghtmltopdf"

Precompiled gems are distributed, so you do not need a Rust toolchain to install it. The supported platforms are x86_64-linux, aarch64-linux, and arm64-darwin (glibc), on Ruby 3.2 or later.

No external process is started. Conversion happens inside your own process as a native extension built with magnus and rb-sys. The GVL is released while the heavy work runs, so other Puma threads keep going.

See Ruby / Rails for how to use it.

About fonts

Without --font, the fonts installed on the system are used. For documents that contain Japanese, we recommend naming a font file explicitly, or using the Docker image, which bundles fonts.

sghtmltopdf invoice.html \
  --font NotoSansJP-Regular.ttf \
  --gothic-font NotoSansJP-Regular.ttf

See Fonts for details.