https://github.com/threez/hpdf.cr
Create PDF documents in crystal using libhpdf / libharu
https://github.com/threez/hpdf.cr
Last synced: 9 months ago
JSON representation
Create PDF documents in crystal using libhpdf / libharu
- Host: GitHub
- URL: https://github.com/threez/hpdf.cr
- Owner: threez
- License: mit
- Created: 2022-07-26T07:00:25.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-21T16:46:58.000Z (about 2 years ago)
- Last Synced: 2025-03-31T03:12:00.759Z (over 1 year ago)
- Language: Crystal
- Size: 3.61 MB
- Stars: 16
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hpdf [](https://github.com/threez/hpdf.cr/actions/workflows/ci.yml) [](https://threez.github.io/hpdf.cr/)
Shard to create PDF documents with crystal using [libharu/libhpdf](https://github.com/libharu/libharu/).
Example renderings of the example files and specs:
[](pdfs).
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
hpdf:
github: threez/hpdf.cr
```
2. Run `shards install`
## Usage
```crystal
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
Before usage you have to install the library **libharu** which
depends on **libpng** and **zlib**:
SystemCommand
Alpineapk add libharu
Debian/Ubuntusudo apt install libhpdf-dev
Centossudo yum install libharu-devel
Fedora/Redhatsudo dnf install libharu-devel
FreeBSDpkg install libharu
OpenBSDpkg_add libharu
macOSbrew install libharu
## 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
- [Vincent Landgraf](https://github.com/threez) - creator and maintainer