Git Product home page Git Product logo

raku-wkhtmltox's Introduction

Wkhtmltox

Actions Status

This modules converts HTML code to PDF or Image files using 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

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 & install libwkhtmltox binaries.

  • Install this module using 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 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

raku-wkhtmltox's People

Contributors

azawawi avatar khalidelboray avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

khalidelboray

raku-wkhtmltox's Issues

The approach to search for library is not portable

โžœ  ~ zef install Wkhtmltox
===> Searching for: Wkhtmltox
===> Testing: Wkhtmltox:ver<0.0.1>:auth<github:azawawi>
[Wkhtmltox] Cannot locate native library '(null)': /usr/local/lib/libwkhtmltox.so: cannot open shared object file: No such file or directory
[Wkhtmltox]   in method setup at /home/koto/.rakudobrew/versions/moar-master/install/share/perl6/core/sources/947BDAB9F96E0E5FCCB383124F923A6BF6F8D76B (NativeCall) line 293
[Wkhtmltox]   in block  at /home/koto/.rakudobrew/versions/moar-master/install/share/perl6/core/sources/947BDAB9F96E0E5FCCB383124F923A6BF6F8D76B (NativeCall) line 593
[Wkhtmltox]   in method version at /home/koto/.zef/store/Wkhtmltox-0.0.1.tar.gz/Wkhtmltox-0.0.1/lib/Wkhtmltox/PDF.pm6 (Wkhtmltox::PDF) line 28
[Wkhtmltox]   in block <unit> at t/01-version.t line 8
===> Testing [FAIL]: Wkhtmltox:ver<0.0.1>:auth<github:azawawi>
Aborting due to test failure: Wkhtmltox:ver<0.0.1>:auth<github:azawawi> (use --force-test to override)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.