fawno/php-wkhtmltox

PHP/FFI class for the C library wkhtmltox

0.1.3 2020-02-19 02:09 UTC

This package is auto-updated.

Last update: 2024-11-19 12:34:16 UTC


README

GitHub license GitHub release Packagist PHP

PHP/FFI class for wkhtmltox C library Render HTML into PDF and various image formats using the Qt WebKit rendering engine.

Requirements

Installation

You can install this plugin into your application using composer:

  composer require fawno/php-wkhtmltox

Usage

  require 'vendor/autoload.php';

  use Fawno\PHPwkhtmltox\wkhtmltoimage;

  // Create wkhtmltoimage object (on Windows)
  //$wk = new wkhtmltoimage(__DIR__ . '/bin/wkhtmltox.dll');

  // Create wkhtmltoimage object (on Linux)
  $wk = new wkhtmltoimage('/usr/local/lib/wkhtmltox.so');

  // Set screen Width
  $wk->set_global_setting('screenWidth', '1200');

  // Set url to render
  $wk->set_global_setting('in', 'https://wkhtmltopdf.org/');

  // Set output format to PNG
  $wk->set_global_setting('fmt', 'png');

  // Render url and return image as string
  $data = $wk->convert();

  // Set output filename
  $wk->set_global_setting('out', 'wkhtmltopdf.png');

  // Render url
  $wk->convert();