module Hpdf

Overview

Hpdf is a crystal wrapper of libharu.

HARU is a free, cross platform, open-sourced software library for generating PDF. It supports the following features.

pdf = Hpdf::Doc.build do
  page do
    draw_rectangle 50, 50, width - 100, height - 110

    text Hpdf::Base14::Helvetica, 70 do
      text_out :center, :center, "Hello World"
    end
  end
end

pdf.save_to_file "hello.pdf"

Start building a document using Doc#build

Defined in:

hpdf.cr
hpdf/annotation.cr
hpdf/date.cr
hpdf/destination.cr
hpdf/doc.cr
hpdf/encoding.cr
hpdf/enum.cr
hpdf/error.cr
hpdf/font.cr
hpdf/fonts.cr
hpdf/grid.cr
hpdf/helper.cr
hpdf/image.cr
hpdf/letter.cr
hpdf/libharu.cr
hpdf/outline.cr
hpdf/page.cr
hpdf/raw_image.cr
hpdf/structs.cr
hpdf/table.cr

Constant Summary

LIBHPDF_VERSION = {{ (system(LIBHPDF_VERSION_DETECTION_SCRIPT)).chomp }}

Compile-time-detected libharu version, e.g. "2.3.0" or "2.4.6". Used to switch between the pre-2.4 (UINT16-based) and 2.4+ (HPDF_REAL-based) ABIs of HPDF_Page_SetDash and HPDF_DashMode.

LIBHPDF_VERSION_DETECTION_SCRIPT = "for n in libhpdf libharu; do\n v=$(pkg-config --modversion \"$n\" 2>/dev/null)\n if [ -n \"$v\" ]; then\n echo \"$v\"\n exit 0\n fi\ndone\nfor d in /opt/homebrew/include /usr/local/include /usr/include; do\n for h in $d/hpdf_version.h $d/hpdf.h; do\n [ -f \"$h\" ] || continue\n major=$(awk '/^#define HPDF_MAJOR_VERSION/{print $3; exit}' \"$h\")\n minor=$(awk '/^#define HPDF_MINOR_VERSION/{print $3; exit}' \"$h\")\n if [ -n \"$major\" ]; then\n echo \"$major.$minor\"\n exit 0\n fi\n done\ndone\necho \"2.4\""

Shell script run at compile time to detect the installed libharu version. Tries pkg-config first (works on most Linux installs), then falls back to grepping HPDF_MAJOR_VERSION / HPDF_MINOR_VERSION from the installed headers. Echoes "MAJOR.MINOR" (e.g. 2.4) or 2.4 if nothing was found.

VERSION = "0.9.10"