hpdf

Create PDF documents using libhpdf (libharu)
1.0.0 Latest release released
threez/hpdf.cr
19 1
threez

hpdf .github/workflows/ci.yml https://threez.github.io/hpdf.cr/

Shard to create PDF documents with crystal using libharu/libhpdf.

Example renderings of the example files and specs:

montage.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      hpdf:
        github: threez/hpdf.cr
    
  2. Run shards install

Usage

require "hpdf"

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"

C library dependencies

Requires libharu ≥ 2.4.6, which depends on libpng and zlib.

  • macOSbrew install libharu (ships ≥ 2.4.6)

  • Alpineapk add libharu (check version; build from submodule if < 2.4.6)

  • Arch Linuxpacman -S libharu

  • FreeBSDpkg install libharu

  • OpenBSDpkg_add libharu

  • Debian/Ubuntuapt ships libhpdf 2.3 (too old). Build from the bundled submodule instead:

    git clone https://github.com/threez/hpdf.cr
    cd hpdf.cr
    make libharu   # initialises submodule and builds a static lib; no system install needed
    

    The shard's @[Link] detects and links the built static library automatically.

Development

Use the examples to write demos. Read about libharu here:

  • http://libharu.sourceforge.net/index.html
  • https://github.com/libharu/libharu/wiki

Contributing

  1. Fork it (https://github.com/threez/hpdf.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

hpdf:
  github: threez/hpdf.cr
  version: ~> 1.0.0
License MIT
Crystal 1.4.1

Authors

Libraries 1

  • libhpdf: >= 2.4.6

Dependencies 0

Development Dependencies 1

  • ameba ~> 1.6.0
    {'github' => 'crystal-ameba/ameba', 'version' => '~> 1.6.0'}

Dependents 0

Last synced .
search fire star recently