Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azawawi/raku-wkhtmltox
Convert HTML to PDF / Image using libwkhtmltox
https://github.com/azawawi/raku-wkhtmltox
perl6 wkhtmltoimage wkhtmltopdf wkhtmltox
Last synced: about 1 month ago
JSON representation
Convert HTML to PDF / Image using libwkhtmltox
- Host: GitHub
- URL: https://github.com/azawawi/raku-wkhtmltox
- Owner: azawawi
- License: mit
- Created: 2018-09-21T18:17:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-30T00:04:35.000Z (about 2 years ago)
- Last Synced: 2024-09-30T20:05:38.121Z (about 1 month ago)
- Topics: perl6, wkhtmltoimage, wkhtmltopdf, wkhtmltox
- Language: Raku
- Homepage:
- Size: 71.3 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Wkhtmltox
[![Actions
Status](https://github.com/azawawi/raku-wkhtmltox/workflows/test/badge.svg)](https://github.com/azawawi/raku-wkhtmltox/actions)This modules converts HTML code to PDF or Image files using [`libwkhtmltox`](https://wkhtmltopdf.org/libwkhtmltox/) (aka `wkhtmltopdf`, `wkhtmltoimage`). It does not run `wkhtmltopdf` or `wkhtmltoimage` binaries thus
no extra CPU/memory cost for each conversion operation. It is suitable for batch
HTML to PDF/Image conversions.**Note: This is currently experimental and API may change. Please DO NOT use in
a production environment.**## Example
```raku
use v6;
use Wkhtmltox::PDF;# Print library version
my $version = Wkhtmltox::PDF.version;
say "wkhtmltopdf version: $version";# Create pdf object
my $pdf = Wkhtmltox::PDF.new;# Print global setting values
say $pdf.get-global-setting("size.pageSize");# Set global settings values
$pdf.set-global-setting("size.pageSize", "A4");# Convert HTML to PDF
my $html = "Raku rocks!";
my $pdf-blob = $pdf.render($html);
"sample.pdf".IO.spurt($pdf-blob) if $pdf-blob.defined;# Call only once to cleanup resources
$pdf.destroy;
```## Installation
- Please [download](https://wkhtmltopdf.org/downloads.html) & install
`libwkhtmltox` binaries.- Install this module using [zef](https://github.com/ugexe/zef):
```
$ zef install Wkhtmltox
```## Testing
- To run tests:
```
$ prove --ext .rakutest -ve "raku -I."
```- To run all tests including author tests (Please make sure
[Test::Meta](https://github.com/jonathanstowe/Test-META) is installed):
```
$ zef install Test::META
$ AUTHOR_TESTING=1 prove --ext .rakutest -ve "raku -I."# On windows
$ $env:AUTHOR_TESTING=1; prove --ext .rakutest -ve "raku -I."
```## Author
Ahmad M. Zawawi, azawawi on #raku, https://github.com/azawawi/
## License
MIT License